Writing a message-driven bean: your job as Bean Provider

You put THREE kinds of methods in the bean class:
Bean Law: ejbCreate() method
Write a single, no-argument ejbCreate() method in the bean. It doesn’t match anything or come from any interface. It’s there because it MUST be.
MessageListener implementation: onMessage()
This is your business method. Your only business method.
<<interface>>
MessageListener
onMessage()
MessageDrivenBean implementation: container callbacks
Implement both of the methods from the MessageDrivenBean interface, which your bean must implement in the official Java way (i.e. using the ‘implements MessageDrivenBean’ declaration either in your bean class or one of its superclasses)
<<interface>>
MessageDrivenBean
ejbRemove()
setMessageDrivenContext()
Rules for the message-driven bean class
The class must implement javax.ejb.MessageDrivenBean and javax.jms.MessageListener.
public class ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access