• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

timeout callback method and transaction attribute

 
Ranch Hand
Posts: 1756
12
  • 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: 1756
12
  • 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.
 
Creator of Enthuware JWS+ V6
Posts: 3294
297
Android Eclipse IDE Chrome
  • 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.
 
My, my, aren't you a big fella. Here, have a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!