• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

timeout callback method and transaction attribute

 
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2418
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic