Configure transactions for the SCA JMS binding
We can configure the Service Component Architecture (SCA) Java Message Service (JMS) binding for services and references to take advantage of transaction quality of service behaviors.
The information in this topic applies for both OSOA and OASIS SCA applications.
SCA provides declarative mechanisms in the form of intents for describing the transactional environment required by components.
The SCA JMS binding supports transacting message delivery with the global transaction of a component. The SCA transaction policies are specified as intents that represent quality of service behavior offered by the JMS binding on an SCA service or reference. However, the SCA JMS binding does not propagate transaction context; therefore, the client and service cannot participate in the same global transaction.
To learn more about SCA global transactions, see the SCA transaction intents documentation.
SCA references can use the transactedOneWay intent to transact one-way requests. When the transactedOneWay intent is used on an SCA reference, a one-way request on the reference is not sent until the global transaction of the client is committed. If the global transaction of the client is rolled back, the request is not sent.
SCA services can use the transactedOneWay intent to transact one-way requests only or the exactlyOnce intent to transact both one-way and request-response message patterns. When the transactedOneWay intent is used on an SCA service, a one-way request is received from the JMS binding as part of the component's global transaction. When the exactlyOnce intent is used on a service, both one-way and request-response message patterns are received from the JMS binding as part of the component's global transaction. The receipt of the message, and the sending of the response for request-response messaging, is not committed until the service transaction commits. If the service transaction is rolled back, the message is again made available for delivery or the message is sent to an exception destination based upon the configuration of the bus destination.
The SCA runtime environment typically performs a rollback of a global transaction only if the component produces an unchecked exception error. An unchecked exception error is a subclass of java.lang.RuntimeException or java.lang.Error class. A checked exception does not force a rollback. The component can force a rollback using the UOWSynchronizationRegistry interface. For example:
com.ibm.websphere.uow.UOWSynchronizationRegistry uowSyncRegistry = com.ibm.wsspi.uow.UOWManagerFactory.getUOWManager(); uowSyncRegistry.setRollbackOnly();If a reference does not require a transactedOneWay intent, then one-way requests are sent immediately. If a service does not require the transactedOneWay or exactlyOnce intent, requests are removed from the queue prior to the delivery of the request to the component. If the component processing fails, these requests cannot be delivered again.
- Specify the transactedOneWay or exactlyOnce intents on the SCA service or reference enable transacting message delivery with the global transaction of the component.
Example use of the transactedOneWay and exactlyOnce intents. In this example, the component, TransactionalComponent, receives one-way and request-response messages from the DataUpdate service and subsequently sends one-way requests to the loggingService reference transactionally. If the component transaction rolls back, the active request is queued again and any requests to the reference are not sent.
<component name="TransactionalComponent"> <implementation.java class="example.TransactedImpl" requires="managedTransaction.global"/> <service name="DataUpdate" requires="exactlyOnce"> <binding.jms> <destination name="jms/DataUpdate_Request" type="queue"/> <activationSpec name="jms/SCA_JMS_AS"/> </binding.jms> </service> <reference name="loggingService" requires="transactedOneWay"> <binding.jms> <connectionFactory name="jms/SCA_JMS_CF"/> </binding.jms> </reference> </component>
- Use the console, configure the bus destination to handle failed messages.
- Start the console.
- In the navigation pane, click Service integration > Buses > bus_name > Destinations > destination_queue_name or destination_topic_space_name .
- Under Exception destination, enter a value for the Maximum failed deliveries per message . Maximum number of failed attempts to process a message, after which the message is forwarded from its intended destination to the exception destination. This property applies to individual messages.
Results
You have updated the SCA composite to use transacted message delivery.
Related concepts
SCA transaction intents
Related tasks
Specify bindings in an SCA environment Configure the SCA JMS binding
Service Component Architecture specifications and APIs