• 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

Message.acknowledge()

 
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 Frits' notes, p.37, for container managed transaction,

it is not allowed to use Message.acknowledge() either within a transaction or within an unspecified transaction context.



Question 1: 'either within a transaction or within an unspecified transaction context' means regardless the bean is executing a transaction or not, the bean should never invoke Message.acknowledge() method in onMessage(), lifecycle callback interceptors, timer callback interceptors, business method interceptors or inside business methods?

Question 2: MDB should not invoke Message.acknowledge() because the EJB container will acknowledge the receipt of the message to the messaging provider. In the other words, the container will acknowledge the message on behalf of the MDB. Is this the reason why Message.acknowledge() is not allowed in MDB?

 
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

Question 1: 'either within a transaction or within an unspecified transaction context' means regardless the bean is executing a transaction or not, the bean should never invoke Message.acknowledge() method in onMessage(), lifecycle callback interceptors, timer callback interceptors, business method interceptors or inside business methods?


Be careful: an unspecified transaction context is not the same as no transaction context (check ejb specs 13.6.5 Handling of Methods that Run with "an unspecified transaction context"). But generally spoken: don't use this method when you have a MDB.

Question 2: MDB should not invoke Message.acknowledge() because the EJB container will acknowledge the receipt of the message to the messaging provider. In the other words, the container will acknowledge the message on behalf of the MDB. Is this the reason why Message.acknowledge() is not allowed in MDB?


Exactly.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic