I have a small Spring MVC webapp (which embeds ActiveMQ) that is designed to run in a local Tomcat, and reliably message to a queue on a remote ActiveMQ.
All of that's in place, except for the "reliably". At the moment, if the remote site goes down, the send fails dramatically. My send config:
<!-- Connection setup -->
<bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory"
p:brokerURL="tcp://backend-server-box:61616" />
<bean id="cachedConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory"
p:targetConnectionFactory-ref="connectionFactory"
p:sessionCacheSize="10" />
<!-- Bean that represents the correct destination on the backend server -->
<bean id="backendDestination" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="jmsQueueName" />
</bean>
<bean id="backendTemplate"
class="org.springframework.jms.core.JmsTemplate"
p:connectionFactory-ref="cachedConnectionFactory"
p:defaultDestination-ref="backendDestination" />
<!-- Bean that sends to the correct destination on the backend server -->
<bean id="simpleSender" class="uk.co.mycompany.client.messaging.SimpleSender">
<property name="jmsTemplate" ref="backendTemplate" />
</bean>
I think what I need is a local, persistent broker that the connectionFactory (the first bean defined above) points to, which is aware of the remote broker (a JMS to JMS bridge?) If there's a clear bit of documentation to deal with this I'd be very happy to be pointed at it, but I've had to cobble things together, mostly from the extremely helpful BruceBlog. Or any direct help would be great.
Thanks
Update. Some fixes:
- Eclipse doesn't find the amq namespace properly. This is where you find out why that's broken, and it's an easy fix.
- As Miklos says in a comment below, you need the org.osgi.core-4.1.0.jar in your webapp lib. Get this from the ActiveMQ lib/optional folder.
- You also need the Apache Commons xbean-spring-3.4.jar. Get it here.
- This guide got me through the next few hurdles. It's perfect, except in a couple of places attribute names are incorrect (brokername should be brokerName, and physicalname should be physicalName).
Update 2. I've answered it properly, below. Doesn't need any of that amq stuff!