Social Media

Apache CXF – JMS Spring Config

The JMS Spring Config Demo (samples\jms_spring_config) uses the wsdl_first code, and adds JMS transport through configuration

WSDL

The WSDL remains unchanged, with the port defined –

[sourcecode lang=”xml”] <wsdl:service name="CustomerServiceService">
<wsdl:port name="CustomerServicePort" binding="tns:CustomerServiceServiceSoapBinding">
<soap:address location="http://localhost:9090/CustomerServicePort"/>
</wsdl:port>
</wsdl:service>
[/sourcecode]

Spring Configuration

JMS is configured through the server-applicationContext.xml –

[sourcecode lang=”xml”] <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>

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

<!– JMS Endpoint –>
<jaxws:endpoint xmlns:customer="http://customerservice.example.com/"
id="CustomerServiceHTTP" address="jms://"
implementor="com.example.customerservice.server.CustomerServiceImpl">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
<bean class="org.apache.cxf.transport.jms.JMSConfigFeature" p:jmsConfig-ref="jmsConfig" />
</jaxws:features>
</jaxws:endpoint>
[/sourcecode]

There are 3 point of connectivity –

  • jmsConnectionFactory – Inject ActiveMQConnectionFactory into Spring’s JMS SingleConnectionFactory
  • jmsConfig – Inject the jmsConnectionFactory and queue name
  • jaxws:endpoint – Inject jmsConfig into the jaxws:endpoint

About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About or on my consultancy website Glendevon Software

follow me on:

Leave a Comment: