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

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
ETS User

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

Post 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)."?

ptie1981

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

Post by ptie1981 »

Why "Provide a public no-args constructor for class Y"?

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

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

ptie1981

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

Post 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!

Misha
Posts: 10
Joined: Thu Aug 09, 2012 1:32 am
Contact:

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

Post 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?

Guest

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

Post 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.

Misha
Posts: 10
Joined: Thu Aug 09, 2012 1:32 am
Contact:

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

Post 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.

Guest

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

Post 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.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

Class Y has now been annotated with @MessageDriven to avoid this confusion.

thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.

Christian

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

Post 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).

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests