• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question on Message Driven beans

 
Bobby S Sidhu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im using softSCBCD simulator to study... and I ran across this question
A message-driven bean ProcessOrderBean with container-managed transaction demarcation has the 'Required' transaction attribute specified for its onMessage(javax.jms.Message) method.
If the invocation of onMessage method on ProcessOrderBean instance always results in transition of the bean instance to 'does not exist' state, then which of the following methods might have been invoked from onMessage(javax.jms.Message) method (select the best answer):
A.javax.ejb.EJBContext's setRollbackOnly()
B.javax.ejb.EJBContext's getCallerIdentity()
C.javax.ejb.EJBContext's getRollbackOnly()
D.javax.ejb.MessageDrivenBean's ejbRemove()
Now I chose D ... their answer is B. I see what they are trying to say. Their argument has to do with B causing a system exception resulting in Does not Exist. My question's are,
1.Is there even a getCallerIdentity function in EJBContext? (I didn't see it on the Interface summary at the back of the HF: EJB book, saw getCallerPrincipal but that's not what they wrote, infact they say getCallerPrincipal is another way as well as getEJBLocalHome() and getEJBHome() to throw a system exception.)
2.Wont ejbRemove in javax.ejb.MessageDrivenBean result in a transition from ready to Does Not Exist. Their question mentions nothing about exceptions so I assume D is a better answer than B.
Does it have something to do with the fact that 'invocation of onMessage method on ProcessOrderBean instance always results in transition of the bean instance to 'does not exist' state' is that akin to saying they're throwing a system level exception? As opposed to the container running ejbRemove. Hmmm I may have just answered my own question in writing this post... But I put so much work into it I'll post it anyway just to get some feedback :roll: Thx all
-Bobby
 
Magnus Stattin
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a tricky question...
getCallerIdentity is one of the deprecated methods of the EJBContext. It is mentioned on page 241 in HF.
The question is which of the following methods might have been invoked from onMessage(javax.jms.Message). I think they are trying to say that ejbRemote will not have been called there.
/Best Regards
[ December 15, 2003: Message edited by: Magnus Stattin ]
 
calvin zhu
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on Spec Page 320:
Invoking the getCallerPrincipal and isCallerInRole methods is disallowed in
the message-driven bean methods because the Container does not have a client security context.
The Container must throw and log the java.lang.IllegalStateException if
either of these methods is invoked.
And since java.lang.IllegalStateException is a subclass of RuntimeException, which will be a systemException. It will make the container discard instance.
(on Spec Page 377)
 
Keith Rosenfield
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Booby:
Wont ejbRemove in javax.ejb.MessageDrivenBean result in a transition from ready to Does Not Exist.

ejbRemove would not be invoked on the ProcessOrderBean in the onMessage method since a bean can not call remove on itself. Besides, the container calls ejbRemove not the bean itself.
Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic