Using the JMSConfigFeature - 7.3

Talend ESB Service Developer Guide

Version
7.3
Language
English
Product
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Module
Talend ESB
Talend Runtime
Content
Design and Development
Installation and Upgrade
Last publication date
2023-04-17

Standard JMS transport configuration in CXF is done by defining a JMSConduit or JMSDestination. There is however an easier configuration option more conformant to Spring dependency injection. Additionally the new configuration offers many 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 configuration.

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 connection 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>