Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question on EJB Transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question on EJB Transactions" Watch "Question on EJB Transactions" New topic
Author

Question on EJB Transactions

vishwa venkat
Ranch Hand

Joined: Nov 22, 2003
Posts: 185
I have a transaction, say Trans1, which has 3 transactions ionternally, say, Trans2,Trans3,Trans4.

The transaction time out that I set on server is 5 mins.

what happens if the Trans 2 takes 3 mins and Trans 3 takes 3 mins? Is it gonna timeout the EJB Trans1?

I am using IBM Webspshere application server.

and is these trasnaction rules are vendor dependent?

Thanks,
-Visu
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The transaction timeout relates to a transaction. If a transaction is suspended, the clock stops ticking, so to speak, and will restart when the transaction resumes.

I won't expect five minutes for a timeout as you need to keep transactions small. Something like 30 seconds should be sufficient as a default.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
vishwa venkat
Ranch Hand

Joined: Nov 22, 2003
Posts: 185
Thanks for clarification. One of the EJB constitutes a JMS transaction which will timeout after 4 minutes. so we made the global transaction time out on server to 5mins to take care of that.Let me know if you have any ideas on this too..

thanks a lot.
Sub swamy
Ranch Hand

Joined: Oct 02, 2002
Posts: 121
Isn't JMS(MDB) to be used for "A"synchronous processing ? If the processing is going to be synchronous wont it be better using stateless session bean ? Correct me if otherwise.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
It is not clear what is happening. I think that the requirement is for a JMS message and the message listener (probably an MDB) must be in the same transaction.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Originally posted by visu Ramana:
I have a transaction, say Trans1, which has 3 transactions ionternally, say, Trans2,Trans3,Trans4.

The transaction time out that I set on server is 5 mins.

what happens if the Trans 2 takes 3 mins and Trans 3 takes 3 mins? Is it gonna timeout the EJB Trans1?

I am using IBM Webspshere application server.

and is these trasnaction rules are vendor dependent?

Thanks,
-Visu


How can transaction 1 have 3 transaction internall -Nested transaction are not supported in J2EE.


Groovy
vishwa venkat
Ranch Hand

Joined: Nov 22, 2003
Posts: 185
Nested transactions are supported in J2ee. and coming to the requirement,

We are doing Sunchronous JMS transaction.

So we created two session bean methods one for send and another for receive messages (in BEAN2)and these methods are called from another session bean(say BEAN1)

so BEAN1 method starts transaction and sends a message and recieves message withing the same method. and send ,receive methods open their individual transaction contexts.

Since receive method might take 4 minutes, since we are waiting for response from the JMS Queue, we set the transaction timeout to be 5 mins.

Thanks for carrying the discussion..
vishwa venkat
Ranch Hand

Joined: Nov 22, 2003
Posts: 185
NO MDBs used..it is a Synchronous transaction, we can say it is a Psuedo Synchronous transaction.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Nested transactions are supported in J2ee. and coming to the requirement,

Nested transactions are disallowed by the EJB spec. All transactions are flat and no compliant EJB server will support nested transactions.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
We are doing Sunchronous JMS transaction.

JMS is meant for aynchronous messaging. The synchronous receive() method blocks until a message is produced, the timeout value, if specified, elapses or the application is closed. I strongly recommend that you avoid using blocking receive() calls on the server side because a synchronous receive() call consumes resources for the entire duration that the call is blocked.

Also, consider the effect on the client which might be waiting for up to five minutes for a response.

See if you can redesign your app for asyncronous messaging. Doing it this way, when methods are received asynchronously, the application is notified using a message listener only when a message has been produced. So, no resources are consumed waiting for a message.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8898

Originally posted by Roger Chung-Wee:

Nested transactions are disallowed by the EJB spec. All transactions are flat and no compliant EJB server will support nested transactions.


Thanks. I was shocked to hear that nested transaction is supported in J2EE.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on EJB Transactions
 
Similar Threads
Question on EJB transactions in Websphere
Transaction Timed Out
Configuring transcation timeouts
How to extend timeout / keepalive timeout in Tomcat
How to catch EJB Transaction Timeout?