I'm trying to connect to a HornetQ JMS server running in JBoss 7.1.1 from a standalone Spring Boot application. I can get to the server and push messages to the queue with a configuration like this:
<bean name="hornetConnectionFactory" class="org.hornetq.jms.client.HornetQXAConnectionFactory">
<constructor-arg name="ha" type="boolean" value="false" />
<constructor-arg>
<bean class="org.hornetq.api.core.TransportConfiguration">
<constructor-arg value="org.hornetq.core.remoting.impl.netty.NettyConnectorFactory" />
<constructor-arg>
<map key-type="java.lang.String" value-type="java.lang.Object">
<entry key="host" value="127.0.0.1" />
<entry key="port" value="5445"></entry>
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<bean id="defaultDestination" class="org.hornetq.jms.client.HornetQQueue">
<constructor-arg index="0"
value="outgoingMessageQueue"/>
</bean>
<bean id="userCredsConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="hornetConnectionFactory"/>
<property name="username" value="${jms.user}"/>
<property name="password" value="${jms.password}"/>
</bean>
<bean id="jmsConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" primary="true">
<constructor-arg ref="userCredsConnectionFactory" />
<property name="sessionCacheSize" value="20"/>
</bean>
<bean name="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"
p:connectionFactory-ref="jmsConnectionFactory"
p:defaultDestination-ref="defaultDestination" />
However the XA connection is not participating in JTA transaction that I have enabled through Spring Boot's bitronix support. The database connection is using JTA. How do I get Spring Boot to get this JMS connection to enlist as a XA resource in its transaction manager?
Got it to work now. It was simplier than I thought - I was able to get Spring Boot to connect to JBoss's HornetQ with this in the application.properties:
spring.hornetq.mode=native
spring.hornetq.host=127.0.0.1
spring.hornetq.port=5445
spring.jta.bitronix.connectionfactory.user=user
spring.jta.bitronix.connectionfactory.password=password
And the jmsTemplate picked up the XA JmsConnection automatically. All the earlier XML is not apparently necessary under Boot.