The JMS Transport offers an alternative messaging mechanism to SOAP over HTTP. SOAP over JMS offers more reliable and scalable messaging support than SOAP over HTTP. The SOAP over JMS specification is aimed at a set of standards for the transport of SOAP messages over JMS. Its main purpose is to ensure interoperability between the implementations of different Web services vendors. CXF supports and is compliant with this specification.

SOAP over JMS Namespace

WSDL Namespace

The WSDL extensions for defining a JMS endpoint use a special namespace. In order to use the JMS WSDL extensions you will need to add the namespace definition shown below to the definitions element of your contract.

JMS Extension Namespace

JMS URI

JMS endpoints need to know the address information for establishing connections to the proper destination. SOAP over JMS implements the URI Scheme for Java Message Service 1.0.

This URI scheme starts with "jms:jndi:" plus a JNDI name for a Destination. Since interaction with some resources may require JNDI contextual information or JMS header fields and properties to be specified as well, the "jndi" variant of the "jms" URI scheme includes support for supplying this additional JNDI information as query parameters.

CXF supports three variants, "jndi", "queue", and "topic".
For example:

Properties are as follows:

Property

DefaultValue

Description

deliveryMode

PERSISTENT

NON_PERSISTENT messages will kept only in memory
PERSISTENT messages will be saved to disk

jndiConnectionFactoryName

 

Specifies the JNDI name bound to the JMS connection factory to use when connecting to the JMS destination.

jndiInitialContextFactory

 

Specifies the fully qualified Java class name of the "InitialContextFactory" implementation class to use.

jndiURL

 

Specifies the JNDI provider URL

replyToName

 

Specifies the JNDI name bound to the JMS destinations where replies are sent.

priority

4

Priority for the messages. See your JMS provider documentation for details

timeToLive

0

Time (in ms) after which the message will be discarded by the jms provider

Additional JNDI Parameters

 

Additional parameters for a JNDI provider. A custom parameter name must start with the prefix "jndi-".

For more details about these attributes, please check out the JMS URI specification.

WSDL Extension

Various JMS properties may be set in three places in the WSDL — the binding, the service, and the port. Values specified at the service will propagate to all ports. Values specified at the binding will propagate to all ports using that binding.
For example, if the jndiInitialContextFactory is indicated for a service, it will be used for all of the port elements it contains.

Field

DefaultValue

Description

deliveryMode

PERSISTENT

NON_PERSISTENT messages will only be kept in memory
PERSISTENT messages will be saved to disk

jndiConnectionFactoryName

 

Specifies the JNDI name bound to the JMS connection factory to use when connecting to the JMS destination.

jndiInitialContextFactory

 

Specifies the fully qualified Java class name of the "InitialContextFactory" implementation class to use.

jndiURL

 

Specifies the JNDI provider URL

replyToName

 

Specifies the JNDI name bound to the JMS destinations where replies are sent.

priority

4

Priority for the messages. See your JMS provider doc for details

timeToLive

0

Time (in ms) after which the message will be discarded by the jms provider

jndiContextParameter

 

Additional parameters for a JNDI provider.

Here is an example:

If a property is specified at multiple levels, the setting at the most granular level takes precedence (port first, then service, then binding). In the above example, notice the timeToLive property — for the quickPort port, the value will be 10ms (specified at the port level). For the slowPort port, the value will be 100ms (specified at the service level). In this example, the setting in the binding will always be overridden.

WSDL Usage

For this example:

  • The transport URI (http://www.w3.org/2010/soapjms/) is defined in the <soap:binding>.
  • The jms: URI is defined in the <soap:address>
  • The extension properties are in the <soap:binding>

Publishing an service with the JAVA API

Developers who don't wish to modify the WSDL file can also publish the endpoint information using Java code. For CXF's SOAP over JMS implementation you can write the following:

NOTE: Before you start the server, you need to make sure the JMS broker is stared, you can find some useful code of starting the JMS broker here.

Consume the service with the API

Sample code to consume a SOAP-over-JMS service is as follows:

Even if you want to use the 'queue' or 'topic' variants and avoid dealing with JNDI directly, you still have to specify the two factory parameters in the address: