Version 10

    Message Driven Bean (MDB)

     

    A message driven bean is an EJB that also implements the javax.jms.MessageListener interface.

    The container delivers messages to the onMessage method as messages become available.

     

    Differences from other EJBs

     

    You cannot invoke an MDB, i.e. it is not RPC. You communicate with the MDB by sending messages

    to the Queue or Topic that the MDB is listening on.

     

    The onMessage method is not an EJB method. It is defined in the JMS specification.

    According to that specification it is an application error for the onMessage method to throw a

    RuntimeException, e.g. throwing an EJBException is not allowed.

    The behaviour of applications that do this is not defined by the spec and such applications will not be portable.

     

    Differences from JMS message listeners

     

    Unlike standard JMS MessageListeners, the MDBs are pooled behind a ServerSessionPool.

    This means that unlike a QueueReceivers MessageListener, the order of delivery cannot be guaranteed unless

    you set these pool sizes to 1 (one).