Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop SCA composites > Specify bindings in an SCA environment > Configure the SCA JMS binding


Configure SCA JMS binding wire formats

We can configure the messaging data formats between an SCA application and a JMS producer or consumer, by configuring your SCA application to take advantage of a supported message type and data format. Configure the JMS binding for your SCA application.

JMS producers and consumers use a variety of message types to hold application data payloads. We can use the JMS BytesMessage, ObjectMessage, or TextMessage message types. In some cases, the TextMessage message type might be expected to contain additional structure such as application data in serialized XML format.

Wire format describes the format of the data that is on the wire. For the SCA JMS binding, the wire format is the format of the data in the JMS message that flows through the JMS provider. Because of the variety of message types and formats, SCA services and references that are configured with a JMS binding might require additional configuration so that the runtime environment can perform the marshalling and unmarshalling required to translate between application data formats and the format of the JMS message on the wire. The additional configuration of message types is the specification of the wire format for message handling.

Whether you are configuring an SCA service or reference, it is important to recognize if the wire format is previously established by your existing messaging application infrastructure, or if you are selecting the wire format along with your SCA application. If you are starting with an application with a preexisting messaging infrastructure and you are adding your SCA application to this environment, the wire format is likely already determined by the messaging infrastructure. If you are starting with an SCA application and you intend for this application to interact with future JMS message producers or consumers, you can specify the wire format within your SCA application.

For the cases when the wire format is predetermined, it is expected behavior that the wire format enables a natural mapping to the format expected by your preexisting message producers and consumer when dealing with input and non-exception output. However, exception conditions might not be handled according to the convention for the wire format type in your existing messaging application infrastructure. If you want exceptions to flow over the JMS binding, you might need to adjust the producers or consumers interacting with your SCA application over the JMS binding according to the exception handling behavior.


Procedure

  1. Determine if you are using a wire format that is predetermined by your existing messaging infrastructure or if you are starting with an SCA application and defining the message wire format.
  2. Determine the message type to use for your wire format.

    See Supported message types for SCA JMS binding wire formats.

  3. If you are using a wire format predetermined by your existing messaging infrastructure, add the corresponding wire format element into the composition definition file.
  4. Ensure that your SCA service and service client implementation and interfaces map appropriately for the specific wire format that you selected.
  5. (optional) If you want exception checking to occur over the JMS binding, ensure that the JMS producer and consumer that is interoperating with your SCA application follows the SCA JMS binding exception handling procedures described previously.

  6. If you are starting with an SCA application and defining the message infrastructure, add the appropriate wire format element into the composition definition file, and ensure that your future JMS producer or consumer applications understand how to interoperate with this message data format.


Results

You have configured the a messaging data format between an SCA application and a JMS producer or consumer.


Example

The following examples illustrate the configuration of composite definition files using the various wire format schemes. Component references are configured in an analogous manner

TextMessage with serialized XML wire format that maps data using JAXB

This example illustrates the TextMessage with serialized XML wire format that maps data using JAXB, which is the default wire format:

<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
    targetNamespace="http://test/soa/sca/"
    xmlns:ts="http://tuscany.apache.org/xmlns/sca/1.0"
    name="JBC">

<component name="JAXBComponent">  
<implementation.java class="test.backend.HelloWorldJAXBBackendImpl" />
 
<service name="HelloWorldJAXBService">
   
<interface.wsdl interface="http://test.hello#wsdl.interface(HelloWorld)"/>    
<binding.jms>
     
<destination name="jms/Request1" type="queue" create="never"/>
     
<activationSpec name="jms/AS1"/>
     
<response>
       
<destination name="jms/Response1" type="queue" create="never"/>
       
<connectionFactory name="jms/CF" create="never"/>
     
</response>
    
<!-- No wire format element is necessary, the default is used. -->
  
</binding.jms>
</service>

</component>

ObjectMessage wire format that maps to the java.lang.Object class

This example illustrates the ObjectMessage wire format that maps to the java.lang.Object class:

<component name="SerializableComponent">
<implementation.java class="test.backend.HelloWorldSerializableBackendImpl"/>
<service name="HelloWorldSerializableService">  
<interface.java interface="test.HelloWorldSerializableService"/>  
<binding.jms>    
<destination name="jms/Request2" type="queue" create="never"/>
   
<activationSpec name="jms/AS2"/>
   
<response>      
<destination name="jms/Response2"/>      
<connectionFactory name="jms/CF" create="never"/>    
</response>    
<!-- The wire format element must appear last in the binding definition
               to conform to the schema. -->    
<ts:wireFormat.jmsObject/>  
</binding.jms>
</service>
</component>

TextMessage wire format that maps to single string messages

This example illustrates the TextMessage wire format that maps to single string messages:

<component name="JMSTextBackendComponent">
<implementation.java class="test.backend.HelloWorldTextBackendImpl" />
<service name="HelloWorldTextService"> 
<interface.java interface="test.HelloWorldTextService"/> 
<binding.jms>    
<destination name="jms/Request3"/>    
<activationSpec name="jms/AS3"/>    
<response>       
<destination name="jms/Response3"/>       
<connectionFactory name="jms/CF" create="never"/>    
</response>    
<!-- The wire format element must appear last in the binding definition
               to conform to the schema. -->    
<ts:wireFormat.jmsText/>
</binding.jms>

</service>
</component> 

BytesMessage wire format that maps to single byte array messages

This example illustrates the BytesMessage wire format that maps to single byte array messages:

<component name="JMSBytesBackendComponent">
<implementation.java class="test.backend.HelloWorldBytesBackendImpl" />
<service name="HelloWorldBytesService">
<interface.java interface="test.HelloWorldBytesService"/>
<binding.jms>  
<destination name="jms/Request4"/>  
<activationSpec name="jms/AS4"/>  
<response>    
<destination name="jms/Response4"/>    
<connectionFactory name="jms/CF" create="never"/>
 
</response>
 
<!-- The wire format element must appear last in the binding definition
             to conform to the schema. -->  
<ts:wireFormat.jmsBytes/>

</binding.jms>
</service>

</component>

JMS message wire format that does not extract the message payload and maps to the javax.jms.Message class

This example illustrates the JMS Message wire format that does not extract the message payload and maps to the javax.jms.Message class:

<component name="JMSTextBackendComponent">
<implementation.java class="test.backend.HelloWorldTextBackendImpl" />
<service name="HelloWorldTextService">
<interface.java interface="test.HelloWorldTextService"/>
<binding.jms>  
<destination name="jms/Request4"/>  
<activationSpec name="jms/AS4"/>  
<response>    
<destination name="jms/Response4"/>    
<connectionFactory name="jms/CF" create="never"/>  
</response>
 
<!-- The wire format element must appear last in the binding definition
             to conform to the schema. -->  
<ts:wireFormat.jmsText/>

</binding.jms>
</service>
</component>

Examples of TextMessage messages using JAXB

The following examples illustrate the contents of TextMessage messages produced by using JAXB marshalling in the default wire format. These examples are based on using the bottom-up approach of developing SCA applications starting with a Java interface, rather than the best practice of starting with a WSDL interface, such that the runtime environment generates the WSDL file.


Related


Supported message types for SCA JMS binding wire formats
Configure JMS binding request and response wire formats
Specify bindings in an SCA environment
Configure the SCA JMS binding
Use business exceptions with SCA interfaces
Develop SCA services from existing WSDL files


Related


Service Component Architecture specifications and APIs

+

Search Tips   |   Advanced Search