Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

timeout callback method and transaction attribute

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p.90 of Frits's notes,
Quote A:

A timeout callback method on a bean with CMT has transaction attribute REQUIRED or REQUIRES_NEW.


Quote B:

The container must begin a new transaction (CMT) prior to invoking the timeout callback method....


My question is:
When the attribute is REQUIRES_NEW, the container begins a new transaction to invoke the timeout callback method.
But when the attribute is REQUIRED, the container will execute the timeout callback method within the client's transaction.
But in quote B, it says the container will start a new transaction. That means we should not use REQUIRED for the timeout method?
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I can answer my own question:

on JSR 318, p.523:

The container must start a new transaction if the REQUIRED transaction attribute is used. This transaction attribute value is
allowed so that specification of a transaction attribute for the timeout callback method can be defaulted.


Technically, REQUIRED is treated as REQUIRED_NEW for timeout callback method's transaction.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But when the attribute is REQUIRED, the container will execute the timeout callback method within the client's transaction.

There is no client when it comes to timeout callback methods -> the container will invoke the method.

If there is no annotation on the timeout callback it will be defaulted to REQUIRED, and the container will start a new transaction. You can also add the REQUIRES_NEW annotation, however the behaviour will be the same: the container will start a new transaction for the timeout method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic