Question is from WhizLabs Diagnostic Exam - Question 21
Which of the following are valid statements regarding the message listener interface required by the message driven bean?
[A] Bean's message listener interface cannot define more than one message listener method.
[B] For multiple methods in message listener interface, it is resource adaptor, which determines which method to call.
[C] Message listener interface has no role to play in determining the supported messaging type by a message driven bean.
[D] Message listener interface actually distinguishes the messaging type a message bean can support
According to WhizLabs, B and D are the correct answers.
I couldn't understand anything about this. Can someone tell me what is this message listener interface, and will it appear on the real exam?
@MessageDriver annotation has an element whose name is messageListenerInterface. You can specify it this way, or by simply implementing the interface. Most of the time for the exam it is javax.jms,MessageListener with its onMessage() method.
This question actually has two pairs, A or B, C or D. For the first pair, I am not sure. For the second pair, take the example of JMS MessageListner, the onMessage(Message msg) need the JMS message type. So it actually distinguish the message type, which is a javax.jms.Message.
The thing that is confusing here is almost all the examples for MDB is using JMS MessageListener, so our thinking is confined on it. And JMS has its own message types, ObjectMessage, TextMessage and so on. MDB can not distinguish these types. But the "message type" here means a bigger scope. That is, other than JMS, MDB can support other message system.
So for the first pair, the JMS MessageListener only has one method onMessage(). That doesn't mean other message system can only have one method.
Is my understanding right?
subject: Message listener interface of a Message-Driven Bean?