You 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.
JMS producers and consumers use a variety of message types to hold application data payloads. You 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.
You have configured the a messaging data format between an SCA application and a JMS producer or consumer.
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
<?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
<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
<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
<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
<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
package com.ibm.test.soa.sca; public String getGreetings(String name);
<ns2:getGreetings xmlns:ns2="http://sca.soa.test.ibm.com/"> <arg0>Mike</arg0> </ns2:getGreetings>The response message must be a TextMessage with XML payload similar to the following:
<ns2:getGreetingsResponse xmlns:ns2="http://sca.soa.test.ibm.com/"> <return>Hello Mike</return> </ns2:getGreetingsResponse>Similarly, an SCA service bound to a destination, from which TextMessage messages of this format were delivered, requires the same service interface method; for example:
package com.ibm.test.soa.sca; public String getGreetings(String name);
package com.ibm.test.soa.sca; public void getGreeting(FullName name, String string);
<schema targetNamespace="http://www.ibm.com/test/soa/sca/" elementFormDefault="qualified" xmlns=http://www.w3.org/2001/XMLSchema> <complexType name="FullName"> <sequence> <element name="firstName" type="string"/> <element name="lastName" type="string"/> </sequence> </complexType> </schema>
<ns2:getGreetings xmlns:ns2="http://sca.soa.test.ibm.com/"> <arg0>Mike</arg0> </ns2:getGreetings>The response message must be a TextMessage request message with XML payload similar to the following:
<ns3:getGreeting xmlns:ns3="http://sca.soa.test.ibm.com/" xmlns:ns2="http://www.ibm.com/test/soa/sca/"> <arg0> <ns2:firstName>Bob</ns2:firstName> <ns2:lastName>Jones</ns2:lastName> </arg0> <arg1>home</arg1> </ns3:getGreeting>Similarly, an SCA service bound to a destination, from which TextMessage messages of this format were delivered, requires the same service interface method; for example:
package com.ibm.test.soa.sca; public String getGreeting(FullName name, String string);
In this information ...Subtopics
Related tasks
Related reference
| IBM Redbooks, demos, education, and more(Index) |