• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

MDB Message Redelivery and discard

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey there,
I am so much confused about what happens on onMessage method of MDB. Can you answer below cases one by one?
Thanks in advance


1. onMessage (with Required attribute) calls other bean (with required also) where other bean gets a system exception.
Result : Other bean is discarded, MDB Transaction is rolledback and same message will be redelivered to onMessage method again.

2. onMessage (with Not_supported attribute) calls other bean (with required ) where other bean gets a system exception.
Result : Other bean is discarded, what happens to MDB? What it throws? Is the message redelivered to it again or is it simply discarded?

3. onMessage itself throws a system exception.
Result : MDB is discarded, it throws this system exception to container.

4. onMessage itself throws ApplicationException???
Result : ???

5. i set context.setRollBackOnly explicitliy on onMessage method with required attribute.
Result : ???
 
Tony romer
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any help
 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

2. onMessage (with Not_supported attribute) calls other bean (with required ) where other bean gets a system exception.
Result : Other bean is discarded, what happens to MDB? What it throws? Is the message redelivered to it again or is it simply discarded?


System Ex. - Discard the instance
No Tx - no rollback, no re-delivery


4. onMessage itself throws ApplicationException???
Result : ???


Assuming default Tx_Atrribute - Required,
App.Ex - Tx roll back, msg re-delivered.

i set context.setRollBackOnly explicitliy on onMessage method with required attribute.
Result : ???


with Required attribute - means its CMT,
context.setRollbackOnly - it can be done only with BMT,
so illegalStateException raised, bean instance discareded

Since its with Required attribute, & Tx not completed,
msg re-delivered, for sometimes but it's going to discard bean instance everytime,
so msg would be marked poison-msg & added to poison-msg queue.


Any comments?


Thanks.

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

with Required attribute - means its CMT, context.setRollbackOnly - it can be done only with BMT, so illegalStateException raised, bean instance discareded



I think you meant the opposite, EJBContext.setRollbackOnly can be called only by Beans using CMT. If you call it from beans using BMT you will get IllegalStateException.

As for the original question, I suggest

1) Reading section 14.3.4 from core spec
2) Trying all the scenarios out with some code.

When using BMT or CMT, if there is a system exception in the onMessage method, the message will be redelivered. If the bean uses BMT and sets the transaction to rollback, then the message is not redelivered. If the bean uses CMT (Required) and sets the transaction to rollback, then the message is redelivered.
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I think you meant the opposite, EJBContext.setRollbackOnly can be called only by Beans using CMT. If you call it from beans using BMT you will get IllegalStateException.


You are correct, I messed up.

And in any case I was wrong as you have mentioned in next statement.

When using BMT or CMT, if there is a system exception in the onMessage method, the message will be redelivered. If the bean uses BMT and sets the transaction to rollback, then the message is not redelivered. If the bean uses CMT (Required) and sets the transaction to rollback, then the message is redelivered.

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


1. onMessage (with Required attribute) calls other bean (with required also) where other bean gets a system exception.
Result : Other bean is discarded, MDB Transaction is rolledback and same message will be redelivered to onMessage method again.


CORRECT


2. onMessage (with Not_supported attribute) calls other bean (with required ) where other bean gets a system exception.
Result : Other bean is discarded, what happens to MDB? What it throws? Is the message redelivered to it again or is it simply discarded?


Since MDB has transaction NOT_SUPPORTED, auto commit happens as soon as message is picked up by the listener even before calling omMessage(). By the time system exception occurrs in other bean, message is already commited and hence will not be redelivered.


3. onMessage itself throws a system exception.
Result : MDB is discarded, it throws this system exception to container.


If MDB has transaction NOT_SUPPORTED, message is already commited and hence will not be redelivered..
If MDB has transaction REQUIRED, message is will be redelivered..


4. onMessage itself throws ApplicationException???
Result : ???


Application exception does not cause transaction to roll back hence message will not be redelivered..



5. i set context.setRollBackOnly explicitliy on onMessage method with required attribute.
Result : ???


MDB has transaction REQUIRED attribute hence transaction will rollback and message is will be redelivered..
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1. onMessage (with Required attribute) calls other bean (with required also) where other bean gets a system exception.
Result : Other bean is discarded, MDB Transaction is rolledback and same message will be redelivered to onMessage method again.



In my opinion..Yes

2. onMessage (with Not_supported attribute) calls other bean (with required ) where other bean gets a system exception.
Result : Other bean is discarded, what happens to MDB? What it throws? Is the message redelivered to it again or is it simply discarded?



In my opinion..Other bean is discarded. Future course should happen, depending on how system exception is handled by MDB. If it suppresses it then nothing will happen. If it further throws it back then this MDB is discarded too. Assuming MDB is discarded, redelivery depends on Vendor.
Referring to the link, http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/cmb_trans.html
Redelivery depends on Sync Point (used in Websphere) even if there is no transaction

3. onMessage itself throws a system exception.
Result : MDB is discarded, it throws this system exception to container.


Redelivery depends on the above discussion.

4. onMessage itself throws ApplicationException???
Result : ???


Reading from some other post
https://coderanch.com/t/465589/java-EJB-SCBCD/certification/Application-Exception-MDB

"As per section 5.4.17 of EJB 3.0 Core specification, a message-driven bean’s message listener method must not throw the java.rmi.RemoteException. It can throw any other exception. If it throws an application exception marked with rollback, the transaction (if any) is rolled back, the exception is rethrown to the resource adapter, and the bean is NOT discarded. If it throws a system exception, the exception is logged, the transaction (if any) is rolledback, and the bean is discarded. "


5. i set context.setRollBackOnly explicitliy on onMessage method with required attribute.
Result : ???


Since MDB has been marked for rollback, the transaction will be rollback and message will be redelivered.
 
a wee bit from the empire
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic