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

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.

JMS URI Scheme

Variants

PrefixDescription
jndiDestination name is a jndi queue name
jndi-topicDestination name is a jndi topic name
queueDestination is a queue name resolved using JMS
topicDestination is a topic name resolved using JMS

Further parameters can be added as query parameters in the URI.

For example:

JMS parameters

Query Parameter

From
Version

DefaultValue

Description

conduitIdSelectorPrefix3.0.0 If set then this string will be the prefix for all correlation ids the conduit creates and also be used in the selector for listening to replies

deliveryMode

 

PERSISTENT

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

durableSubscriptionClientId3.0.1 Optional Client identifier for the connection. The purpose is to associate a connection with a state maintained on behalf of the client by a provider. The only such state identified by the JMS API is that required to support durable subscriptions.
durableSubscriptionName3.0.0  

jndiConnectionFactoryName

 

ConnectionFactory

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.

jndiTransactionManagerName3.0.0 

Name of the JTA TransactionManager. Will be searched in spring, blueprint and jndi.
If a transaction manager is found then JTA transactions will be enabled. See details below.

jndiURL

 

 

Specifies the JNDI provider URL

jndi-*  Additional parameters for a JNDI provider
messageType3.0.0byteJMS message type used by CXF (byte, text or binary)
password3.0.0 Password for creating the connection. Using this in the URI is discouraged
priority3.0.04Priority for the messages. See your JMS provider documentation for details. Values range from 0 to 9 where 0 is lowest priority

replyToName

 

 

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

receiveTimeout3.0.060000Timeout in milliseconds the client waits for a reply in case of request / repy exchanges
reconnectOnException

deprecated

in 3.0.0

trueShould the transport reconnect in case of exceptions. From version 3.0.0 on the transport will always reconnect in case of exceptions
sessionTransacted3.0.0falseSet to true for resource local transactions. Do not set if you use JTA
targetService   

timeToLive

 

0

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

topicReplyToName  Reply to messages on a topic with this name. Depending on the variant this is either  a jndi or jms name.
useConduitIdSelector3.0.0true

Each conduit is assigned with a UUID. If set to true this conduit id will be the prefix for all correlation ids. This allows several endpoints to

share a JMS queue or topic

username

3.0.0

 

Username for creating the connection

Some of these attributes are specified in the JMS URI specification.

WSDL Extension

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.

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.

JMS Properties. For details refer to the URI query parameters with the same name:

Name

deliveryMode

jndiConnectionFactoryName

jndiInitialContextFactory

jndiURL

replyToName

priority

timeToLive

jndiContextParameter

Here is an example:

Ways to define a Service with JMS transport

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:

Greeter Service with JMS transaport  Expand source
  • 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>

Define service endpoint or proxy in spring or blueprint

The JAXWS endpoint or proxy can be defined like in the SOAP/HTTP case. Just use a jms: uri like described above.

In CXF 3 it is possible to omit the jndi settings. Just specify an endpoint like this:

Endpoint in spring

or a Client like this:

Proxy in spring

The connection factory will be looked up as a bean in the context. By default the name "ConnectionFactory" is assumed but it can be configured using the jndiConnectionFactoryName uri parameter.

Alternatively the connection factory can be set using the ConnectionFactoryFeature.

Publishing a 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: For tests it can be useful to create an embedded broker like this:

Consume the service with the API

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

If you specify queue or topic as variant and use cxf >= 3.0.0 then the jndi settings are not necessary.

In this case case the connection factory is supplied using a feature. For CXF 2.x the connection factory can only be supplied using jndi.