Transaction Behavior Question
andy.miller Feb 16, 2010 3:37 PMI have an application that has a servlet that calls a stateless session bean.
That stateless session bean, in turns enqueues messages (10 of them) into a JMS queue.
There is then an MDB, with its onMessage method, and that method, in turn calls back to the same stateless session bean to process the message(s) (a different method of course.
I have the method for enqueue's the messages to the queue with the default transaction attribute, which should be REQUIRES (no annotation), and its method should commit on exit after enqueueing its messages.
Then the onMessage method should be also REQUIRES, since and MDB can only have REQUIRES or NOT_SUPPORTED as its transaction attributes.
Now, when the onMessage method calls the other method in the same stateless session bean that enqueued the message the MDB dequeued, that method is mark as REQUIRES_NEW, using the @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) annotation, and it also has a @TransactionTimeout(1200) annotation to override the default timeout of 300 seconds. So, I'm expecting that the transaction from the onMessage method to be suspended, and a new transaction to be created with a timeout of 1200 seconds, but the transaction timeouts at five mintues every time.
So, in summary Servlet's doGet -> StatelessBean.queueMessages -> MDB.onMessage -> StatelessBean.doWork
My expected result is a new transaction is created on the queueMessages method, and when it successfully returns (which it does) from enqueueing the message, it commits (persistent messages). Then the MDB.onMessage method starts a new transaction, which gets suspended when it calls StatelessBean.doWork, and on that method a new transaction is started with a timeout of 1200 seconds. When that method completes, its transaction is committed, and when we return to the MDB.onMessage method, its transaction is resume, and committed.
Is there some behavior that I misunderstood? I even tried putting a @TransactionTime(1200) on the onMessage method of the MDB, but that didn't change the behavior. I understood that when you cross bean boundaries is the only point in which you can change the transaction propagation, and that's what I'm doing.
Anyway, any help in why this doesn't work would be appreciated, and JBoss AS 5.1.0 is the target.