• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Message.acknowledge()

 
Bartender
Posts: 2162
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: 3398
312
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.
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic