Designing an enterprise application to use message-driven beans

This topic describes things to consider when designing an enterprise application to use message-driven beans.

About this task

The considerations in this topic are based on a generic enterprise application that uses one message-driven bean to retrieve messages from a JMS queue destination and passes the messages on to another enterprise bean that implements the business logic.

To design an enterprise application to use message-driven beans, complete the following steps:

Procedure

  1. Identify the message listener interface for the message type that the message-driven beans is to handle. The message-driven bean class must implement this message listener interface. For example, an EJB message-driven bean class used for JMS messaging must implement the javax.jms.MessageListener interface.
  2. Identify the resources that the application is to use. This helps to identify the properties of resources that need to be used within the application and configured as application deployment descriptors or within WebSphere Application Server.
    Table 1. JMS resource types and examples of their properties
    JMS resource type Properties (for example)
    JMS connection factory
    Name: SamplePtoPQueueConnectionFactory
    JNDI Name: Sample/JMS/QCF
    JMS destination
    Name: Q1
    JNDI Name: Sample/JMS/Q1
    J2C activation specification properties
    Name: MyMDBsActivationSpec
    JNDI Name: eis/MyMDBsActivationSpec
    Destination JNDI Name: MyQueue
    Destination type: javax.jms.Queue
    
    Message-driven bean (deployment properties)
    Name: JMSppSampleMDBBean 
    Transaction type: Container
    Message selector: JMSType='car'
    Acknowledge mode: Dups OK Acknowledge
    Destination type: javax.jms.Queue
    ActivationSpec JNDI name: MyMDBsActivationSpec
    Business logic bean
    Name: MyLogicBean

    Ensure that you use consistent values where needed; for example, the JNDI name for the J2C activation specification must be the same in both the activation specification and the Message-driven bean's deployment properties.

  3. Separation of business logic. You are recommended to develop a message-driven bean to delegate the business processing of incoming messages to another enterprise bean. This provides clear separation of message handling and business processing. This also enables the business processing to be invoked by either the arrival of incoming messages or, for example, from a WebSphere J2EE client.
  4. Security considerations. Messages arriving at a destination being processed by a listener have no client credentials associated with them; the messages are anonymous. Security depends on the role specified by the RunAs Identity for the message-driven bean as an EJB component. For more information about EJB security, see EJB component security.
  5. Discarding of best-effort non-persistent messages with the default messaging provider. If you configure a JMS destination (queue or topic) to use the default messaging provider, you can configure the maximum reliability of messages on the bus destination to which the JMS destination is assigned.For non-transactional JMS message-driven beans and MessageListeners that use a JMS destination configured on the default messaging provider, best-effort nonpersistent messages are not recoverable. In this case, if a message is unlocked because the message-driven bean or MessageListener threw an exception, then the message is not redelivered or sent to the exception destination because it was deleted from the message store when it was passed to the listener. If you want better message reliability for non-transactional JMS message-driven beans and MessageListeners, you should configure a different option for the Maximum reliability property of the bus destination.



In this information ...


IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 31, 2013 12:02:36 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-zos&topic=tmb_desap
File name: tmb_desap.html