Invoking operations using JMS binding operation selection
We can invoke an operation using JMS binding operation selection. By default, a JMS binding uses the JMS binding operation selection.
Configure the JMS binding for the SCA application.
The JMS binding operation selection is the default binding selection. Thus, this operation selection applies if no operation selection element is specified in the composite definition file. To specify the JMS binding operation selection, add the following operation selection element to the composite definition file:
OSOA
{http://tuscany.apache.org/xmlns/sca/1.0}operationSelector.jmsdefault
OASIS
{http://docs.oasis-open.org/ns/opencsa/sca/200912}operationSelector.jmsDefault
Specify a JMS binding operation selection on an SCA service interface and on an SCA reference.
- In a composite definition file, specify a JMS binding operation selection on an SCA service interface.
Because a given service can define multiple operations, the runtime environment must define mechanisms and algorithms to take a message from a destination bound from an SCA service using the SCA JMS binding, and invoke the correct operation on the SCA service implementation.
The JMS binding defines a String message property called scaOperationName. When receiving a request at a service, or a callback at a reference, the JMS binding uses the following algorithm to determine the operation name:
- If there is only one operation on the service interface, it is assumed that this operation is the operation name for the request.
- Otherwise, if the JMS property scaOperationName is set, the value of this property is used as the operation name.
- Otherwise, if the message is a JMS text or bytes message containing XML, then the selected operation name is taken from the local name of the root element of the XML payload. This operation selection behavior is only supported over the jmsdefault and the jmsTextXML and jmsBytesXML wire formats.
- Otherwise, it is assumed that the operation name is onMessage.
- In a composite definition file, specify a JMS user property operation selection on an SCA reference.
When using the JMS user operation selector on the service side, the reference side or service side callback must set the matching JMS user property. In the service-side example, the operation selector uses the value of the jmsTestUserProp to determine the target operation. We can set this property for the reference or callback side by specifying one or more header properties in the operationProperties element; for example:
<operationProperties name="proxyMethodName"> <headers> <property name="jmsTestUserProp">remoteMethodName</property> </headers> </operationProperties>In the example, a call to the proxyMethodName on the reference side sets the jmsTestUserProp user property to remoteMethodName. The proxyMethodName target operation is set to remoteMethodName when the service-side operation selector is configured as in the previous step.
Results
You have configured a JMS binding operation selection.
What to do next
Deploy and test the operation selection in the SCA application.
Related tasks
Configure the SCA JMS binding Invoking operations using JMS user property operation selection
Service Component Architecture specifications and APIs