Programming rules for creating MDB

7 April 2012 By Nithya Vasudevan 3,486 views No Comment
1 Flares Twitter 1 Facebook 0 Google+ 0 1 Flares ×
  • MDB class must directly (using implements keyword) or indirectly (using annotation or descriptors) implement a message listener interface. Example,
    • Using implements keyword
      public class QueueListenerMDB implements MessageListener {
    • Using annotation
      @MessageDriven(messageListenerInterface= MessageListener.class)
      public class QueueListenerMDB {
  • It is a POJO class and marked with @MessageDriven annotation
  • The MDB class must be declared as public.
  • The class cannot be either final or abstract.
  • The class must have no-argument constructor. Container uses this constructor to create MDB instance.
  • You must implement the methods defined in message listener interface. The methods must be public and cannot be static or final.
  • You must not throw javax.rmi.RemoteException or any runtime exception. If a RuntimeException is thrown then the MDB instance is terminated.

Tags: , , , ,