What is Message driven bean and it's life cycle?

Message driven bean process messages asynchronously are deliver via JMS. M.D.B’s are stateless, server side, transaction aware components used for asynchronous JMS messages. It acts as a JMS message listener which JMS messages, the messages may be sent by any J2ee component, an application client, another enterprise bean, or by a JMS application.
     When EJB application server starts it parse the D.D and then loads and initializes declared beans. In case of M.D.B container establish a connection with the message provide(MOM server), client access message beans through the beans JMS interface (java.JMS.messageListerner) which exposes a single method.
 
Message driven bean’s life cycle
  • EJB container creates a pool of message-driven bean instances
  • For each instance, the EJB container instantiates the bean :
    • It calls the setMessageDrivenContext
    • It calls the instance's ejbCreate
  • Like a stateless session bean,it’s never passivated, It has only two states:
    • Nonexistent 
    • Ready to receive messages.
  • is only a bean class – no interfaces 
  • While in the ready state :
    • EJB container may call onMessage
    • EJB container may call the ejbRemove
 


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email