Page 1 of 1

About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Sun Nov 13, 2011 12:49 pm
by ETS User
Possible inconsistency between answer marked as true:

"Make Y implement MessageListener instead of MessageDrivenBean."

and explanation:

"MessageDrivenBean is not required in EJB 3.x. A valid JMS MDB should use @MessageDriven on the class and the class must implement javax.jms.MessageListener interface. MessageListener interface has only one method - onMessage(Message msg)."?

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Sun Nov 20, 2011 7:01 am
by ptie1981
Why "Provide a public no-args constructor for class Y"?

By default, class Y has a public no-args constructor.

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Sun Nov 20, 2011 9:44 pm
by admin
Hello,
The explanation looks ok. An MDB is not required to implement the MessageDrivenBean interface anymore. But it must implement MessageListener interface. Since Y extends X, it already has the method required for this interface.

No-args constructor is required for Y because it has a one-arg constructor already defined. So it will not get the default no-args constructor automatically.

HTH,
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Mon Nov 21, 2011 2:40 pm
by ptie1981
Your right, I did not noticed it :oops:

But anyway, today I passed the exam with 93%, thanks to the mock exams. Thanks!

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Fri Oct 12, 2012 10:41 am
by Misha
None of the options indicates adding @MessageDriven, so with all the options selected it still won't be a valid MDB. Or am I missing something?

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Fri Oct 12, 2012 2:16 pm
by Guest
Misha wrote:None of the options indicates adding @MessageDriven, so with all the options selected it still won't be a valid MDB. Or am I missing something?
You can describe it as MDB in the deployment descriptor, so an annotation is not strictly required.

I believe the same is true about all EJB annotations.

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Fri Oct 12, 2012 10:36 pm
by Misha
Guest wrote:You can describe it as MDB in the deployment descriptor, so an annotation is not strictly required.
I believe the same is true about all EJB annotations.
In this case option 3 is correct too:
"Make Y implement MessageListener also".
Although it says MessageDrivenBean is not required, it's not forbidden either.

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Sat Oct 13, 2012 9:53 am
by Guest
Misha wrote:Although it says MessageDrivenBean is not required, it's not forbidden either.
As a matter of fact - yes. My glassfish just allowed me to build an MDB with both MessageListener and MessageDrivenBean interfaces, and it works. IT even calls the MessageDrivenBean methods when expected.

Don't know wha to make out of it.

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Sat Oct 13, 2012 5:06 pm
by admin
Class Y has now been annotated with @MessageDriven to avoid this confusion.

thank you for your feedback!
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Sat Nov 24, 2012 12:43 pm
by Christian
Proposal for improvement of explanation:
Make Y implement MessageListener instead of MessageDrivenBean.
is true and
Make Y implement MessageListener also.
is false not because of
MessageDrivenBean is not required in EJB 3.x. A valid JMS MDB should use @MessageDriven on the class and the class must implement javax.jms.MessageListener interface. MessageListener interface has only one method - onMessage(Message msg).
since - as someone has already pointed out - the bean can both be annotated with @MessageDriven and implement the interface MessageDrivenBean, but because Y does not implement the methods from the MessageDrivenBean interface (ejbRemove and setMessageDrivenContext).

Re: About Question enthuware.oce-ejbd.v6.2.507 :

Posted: Wed Nov 28, 2012 7:21 am
by admin
Christian wrote:Proposal for improvement of explanation:
Make Y implement MessageListener instead of MessageDrivenBean.
is true and
Make Y implement MessageListener also.
is false not because of
MessageDrivenBean is not required in EJB 3.x. A valid JMS MDB should use @MessageDriven on the class and the class must implement javax.jms.MessageListener interface. MessageListener interface has only one method - onMessage(Message msg).
since - as someone has already pointed out - the bean can both be annotated with @MessageDriven and implement the interface MessageDrivenBean, but because Y does not implement the methods from the MessageDrivenBean interface (ejbRemove and setMessageDrivenContext).
The explanation that you have quoted is associated with the second option "Make Y implement MessageListener instead of MessageDrivenBean.".

Additional explanation has been added as per your suggestion.

thank you for your feedbac,
Paul.