• Post Reply Bookmark Topic Watch Topic
  • New Topic

can there be MDB without onMessage method

 
Samanthi perera
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read this from tutorial
It is recommended, but not required, that a message-driven bean class should implement the MessageListener interface for the message type it supports. This interface defines only one method onMessage( ). When the EJB container arrives a message, it calls the onMessage( ) method of the message-driven bean to process the message


then which method to call EJB container?
 
Krum Bakalsky
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There can be a lot of messaging systems in a JavaEE environment, JMS is just one of them.
As a messaging system, JMS defines a message listener interface, called javax.jms.MessageListener. It has only one message listener method - onMessage().
Every MDB that is based on JMS, i.e. a JMS-MDB must implement this interface and hence its single onMessage() method.

If there are other messaging systems (based on a JCA integration) supported in your JavaEE server, they can have different message listener interfaces, that can include a set of message listener methods (including more than one). So, the corresponding MDB must implement the particular message listener interface, and hence its set of message listener methods.

I am not an expert in the integration between the JMS provider and the EJB container, in most of the cases it is proprietary (because there is no spec for this).
Other messaging systems, however, are integrated with the EJB container, via Java Connector Architecture and resource adapters.

I am not a JavaEE guru, but i hoped i haven't lied to you ;) (at least not a lot...)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!