You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

In older CXF version the JMS transport is configured by defining a JMSConduit or JMSDestination. Starting with CXF 2.0.9 and 2.1.3 the JMS transport includes an easier configuration option that is more conformant to the spring dependency injection. Additionally the new configuration has much more options. For example it is not necessary anymore to use JNDI to resolve the connection factory. Instead it can be defined in the spring config.

The following example configs use the p-namespace from spring 2.5 but the old spring bean style is also possible.

Inside a features element the JMSConfigFeature can be defined.

 <jaxws:client id="CustomerService"
	xmlns:customer="http://customerservice.example.com/"
	serviceName="customer:CustomerServiceService"
	endpointName="customer:CustomerServiceEndpoint" address="jms://"
	serviceClass="com.example.customerservice.CustomerService">
	<jaxws:features>
		<bean xmlns="http://www.springframework.org/schema/beans"
			class="org.apache.cxf.transport.jms.JMSConfigFeature"
			p:jmsConfig-ref="jmsConfig"/>
	</jaxws:features>
</jaxws:client>

In the above example it references a bean "jmsConfig" where the whole configuration for the JMS transport can be done.

A jaxws Endpoint can be defined in the same way:

<jaxws:endpoint 
	xmlns:customer="http://customerservice.example.com/"
	id="CustomerService" 
	address="jms://"
	serviceName="customer:CustomerServiceService"
	endpointName="customer:CustomerServiceEndpoint"
	implementor="com.example.customerservice.impl.CustomerServiceImpl">
	<jaxws:features>
		<bean class="org.apache.cxf.transport.jms.JMSConfigFeature"
			p:jmsConfig-ref="jmsConfig" />
	</jaxws:features>
</jaxws:endpoint>

The JMSConfiguration bean needs at least a reference to a conncection factory and a target destination.

 <bean id="jmsConfig" class="org.apache.cxf.transport.jms.JMSConfiguration"
	p:connectionFactory-ref="jmsConnectionFactory"
	p:targetDestination="test.cxf.jmstransport.queue"
/>

If your ConnectionFactory does not cache connections you should wrap it in a spring SingleConnectionFactory. This is necessary because the JMS Transport creates a new connection for each message and the SingleConnectionFactory is needed to cache this connection.

 <bean id="jmsConnectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
	<property name="targetConnectionFactory">
		<bean class="org.apache.activemq.ActiveMQConnectionFactory">
			<property name="brokerURL" value="tcp://localhost:61616" />
		</bean>
	</property>
</bean>

JMSConfiguration options:

Name

Default

Description

connectionFactory

(mandatory field)

Reference to a bean that defines a jms ConnectionFactory. Remember to wrap the connectionFactory like described above when not using a pooling ConnectionFactory

targetDestination


JNDI name or provider specific name of a destination. Example for ActiveMQ:
test.cxf.jmstransport.queue

replyDestination



destinationResolver

DynamicDestinationResolver

Reference to a Spring DestinationResolver. This allows to define how destination names are resolved to jms Destinations. By default a DynamicDestinationResolver is used. It resolves destinations using the jms providers features. If you reference a JndiDestinationResolver you can resolve the destination names using JNDI.

transactionManager

none

Reference to a spring transaction manager. This allows to take part in JTA Transactions with your webservice.

taskExecutor

SimpleAsyncTaskExecutor

Reference to a spring TaskExecutor. This is used in listeners to decide how to handle incoming messages. Default is a spring SimpleAsyncTaskExecutor.

useJms11

> CXF 2.1.3: false

true means JMS 1.1 features are used
false means only JMS 1.0.2 features are used

messageIdEnabled

true

 

messageTimestampEnabled

true

 

pubSubNoLocal

false

true do not receive your own messages when using topics

receiveTimeout

0

How many milliseconds to wait for response messages. 0 means wait indefinitely

explicitQosEnabled

false

true means that QoS parameters are set for each message.

deliveryMode

1

NON_PERSISTENT = 1 messages will only be kept in memory

PERSISTENT = 2    messages will be persisted to disk

priority

4

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

timeToLive

0

After this time the message will be discarded by the jms provider

sessionTransacted

false

true means JMS transactions are used

concurrentConsumers

1

minimum number of concurrent consumers for listener

maxConcurrentConsumers

1

maximum number of concurrent consumers for listener

messageSelector


jms selector to filter incoming messages (allows to share a queue)

subscriptionDurable

false

 

durableSubscriptionName


 

messageType

text

text
binary
byte

pubSubDomain

false

false means use queues
true means use topics


  • No labels