If your application cannot use a default JMS binding operation selection or JMS user property operation selection to determine the target operation, you can use a JMS custom operation selector to invoke operations.
Configure the JMS binding for your SCA application.
It is recommended that your SCA component implementations contain only business logic to improve their portability, such as over other bindings. To improve portability, use the custom operation selector to hold the JMS-specific logic that handles an incoming JMS Message, enabling the component implementation to focus on binding-neutral business logic.
You can configure a JMS custom operation selector in an SCA composite definition without any changes to the application. To specify the JMS custom operation selection, add the following operation selection element to the composite definition file:
OSOA
{http://www.ibm.com/xmlns/prod/websphere/sca/1.0/2007/06}operationSelector.jmsCustom
{http://www.ibm.com/xmlns/prod/websphere/sca/1.1}operationSelector.jmsCustom
The custom operation selector must implement the following interface:
package com.ibm.websphere.soa.sca.operationselector.jms.OperationSelector;
import javax.jms.Message;
public interface OperationSelector {
public String getOperationName(Message msg);
public WireFormatContext getWireFormatContext();
public void setWireFormatContext(WireFormatContext ctx);
The interface exposes an instance of javax.jms.Message and enables interaction with the JMS user properties and message body. After doing operation selection, you do not need to use the reset() method to reposition the byte stream cursor for a BytesMessage. The run time automatically resets the cursor in all cases so that the wire format handler is not impacted by the operation selector reading the message first.
If the message body of a BytesMessage is read using any of the read methods available on a BytesMessage, reposition the byte stream to the beginning using the reset() method so that message processors can read the data in the entire message body intended for the targeted operation.
The wire format context is held by an instance of the com.ibm.websphere.soa.sca.wireformat.WireFormatContext class, which is passed with each invocation. The WireFormatContext class provides a java.util.Map interface where you can set property key and value pairs in the context. The WireFormatContext interface also provides several methods to extract useful information about the current context such as component and service names, invocation types, and the ability to mark exceptions. Refer to the Java documentation for the com.ibm.websphere.soa.sca.wireformat.WireFormatContext interface for a complete list of methods.
You have configured a custom operation selector.
Package the operation selection implementation class with your application. The class must be loadable by an application-level class loader.
Deploy and test the operation selector in your SCA application.