Configuring Destination Type Configuring Transaction Management Strategy for an MDB

6 Programming and Configuring MDBs: Details 6-1 6 Programming and Configuring MDBs: Details The topics in this section supplement the instructions in Section 5, Programming and Configuring MDBs: Main Steps. ■ Section 6.1, Configuring Destination Type ■ Section 6.2, Configuring Transaction Management Strategy for an MDB ■ Section 6.3, Configuring MDBs for Destinations ■ Section 6.4, Configuring Message Handling Behaviors ■ Section 6.5, Using the Message-Driven Bean Context ■ Section 6.6, Configuring Suspension of Message Delivery During JMS Resource Outages ■ Section 6.7, Manually Suspending and Resuming Message Delivery ■ Section 6.8, Configuring the Number of Seconds to Suspend a JMS Connection ■ Section 6.9, Configuring a Security Identity for a Message-Driven Bean ■ Section 6.10, Using MDBs With Cross Domain Security ■ Section 6.11, Configuring EJBs to Use Logical Message Destinations

6.1 Configuring Destination Type

Configure the type of destination to which the MDB listens in the destination-type element in the message-driven-destination element of ejb-jar.xml or by using an annotation. ■ To specify a topic, set destination-type to javax.jms.Topic. If the destination is a topic, specify subscription-durability as either Durable or NonDurable . For important additional Topic related settings see Chapter 10, Configuring and Deploying MDBs Using JMS Topics, and Chapter 11, Deployment Elements and Annotations for MDBs. Note: This chapter uses a pre-EJB 3.0 deployment descriptor to illustrate basic MDB configuration. If you plan to use EJB 3.0 annotations, see also Chapter 11, Deployment Elements and Annotations for MDBs. and Chapter 7, Using EJB 3.0 Compliant MDBs, for the equivalent settings. 6-2 Programming Message-Driven Beans for Oracle WebLogic Server ■ To specify a queue, set destination-type to javax.jms.Queue. For additional Queue related settings see Chapter 11, Deployment Elements and Annotations for MDBs.

6.2 Configuring Transaction Management Strategy for an MDB

An MDB can manage its own transactions or defer transaction management to the container. To configure container-level transaction management using descriptor elements: ■ Set the transaction-type element in the message-driven element in the ejb-jar.xml file to Container. ■ Set the trans-attribute element in the container-transaction element in ejb-jar.xml to Required. ■ To change the timeout period for the transaction, set trans-timeout-seconds in the transaction-descriptor element of weblogic-ejb-jar.xml. If a transaction times out, it is rolled back, and the message is redelivered. By default, transactions time out after 30 seconds. For an application with long-running transactions, it may be appropriate to increase the timeout period. To configure container-level transaction management using EJB annotations: import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; ... TransactionAttributevalue = TransactionAttributeType.REQUIRED public void onMessageMessage msg { ... To configure bean-level transaction management using descriptor elements: ■ Set the transaction-type element in the message-driven element in the ejb-jar.xml file to Bean. ■ Set the acknowledge-mode element to specify the desired JMS acknowledgment semantics, either one of the following: – AUTO_ACKNOWLEDGE the default as described at http:java.sun.comproductsjmsjavadoc-102ajavaxjmsSe ssion.htmlAUTO_ACKNOWLEDGE – DUPS_OK_ACKNOWLEDGE as described at http:java.sun.comproductsjmsjavadoc-102ajavaxjmsSe ssion.htmlDUPS_OK_ACKNOWLEDGE For more information, see Session in Programming JMS for Oracle WebLogic Server. Note: If transaction-type is set to Container, and trans-attribute is not set, the default transaction-attribute values are applied: required for EJB 3.0 MDBs and NotSupported for MDBs prior to EJB 3.0. WebLogic Server allows you to deploy the MDB, and logs a compliance error. However, if you make this configuration error, the MDB will not run transactionally—if a failure occurs mid-transaction, updates that occurred prior to the failure will not be rolled back. Programming and Configuring MDBs: Details 6-3

6.3 Configuring MDBs for Destinations