About Question enthuware.oce-ejbd.v6.2.507 :
Moderators: Site Manager, fjwalraven
About Question enthuware.oce-ejbd.v6.2.507 :
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)."?
"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 :
Why "Provide a public no-args constructor for class Y"?
By default, class Y has a public no-args constructor.
By default, class Y has a public no-args constructor.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.507 :
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.
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 :
Your right, I did not noticed it 
But anyway, today I passed the exam with 93%, thanks to the mock exams. Thanks!

But anyway, today I passed the exam with 93%, thanks to the mock exams. Thanks!
-
- Posts: 10
- Joined: Thu Aug 09, 2012 1:32 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.507 :
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 :
You can describe it as MDB in the deployment descriptor, so an annotation is not strictly required.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?
I believe the same is true about all EJB annotations.
-
- Posts: 10
- Joined: Thu Aug 09, 2012 1:32 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.507 :
In this case option 3 is correct too: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.
"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 :
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.Misha wrote:Although it says MessageDrivenBean is not required, it's not forbidden either.
Don't know wha to make out of it.
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.507 :
Class Y has now been annotated with @MessageDriven to avoid this confusion.
thank you for your feedback!
Paul.
thank you for your feedback!
Paul.
Re: About Question enthuware.oce-ejbd.v6.2.507 :
Proposal for improvement of explanation:
is true andMake Y implement MessageListener instead of MessageDrivenBean.
is false not because ofMake Y implement MessageListener also.
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).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).
-
- Site Admin
- Posts: 10384
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.507 :
The explanation that you have quoted is associated with the second option "Make Y implement MessageListener instead of MessageDrivenBean.".Christian wrote:Proposal for improvement of explanation:
is true andMake Y implement MessageListener instead of MessageDrivenBean.is false not because ofMake Y implement MessageListener also.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).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).
Additional explanation has been added as per your suggestion.
thank you for your feedbac,
Paul.
Who is online
Users browsing this forum: No registered users and 9 guests