Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Composite destinations in old style ActiveMQ Spring configuration

$
0
0
Hi everyone,

I've recently been tasked with writing an application that should receive
messages from an existing Spring application (a game server) that uses
ActiveMQ. The game server currently sends messages on a queue called
${jms.queue.audit}, from which another application (called the "auditor")
receives.

What I need to do is configure a new queue, parallell to the
${jms.queue.audit} queue, from which my new application can receive. The
new application should receive exactly the same messages as the auditor.

Since I'm new to both Spring, JMS and ActiveMQ, I first felt a bit lost.
But I understand that what I need to is probably to configure a composite
destination [1], let's call it ${jms.queue.game_events}, which fans out
into two separate queues ${jms.queue.audit} and ${jms.queue.new_queue}.
E.g. like this:

${jms.queue.game_events} ----> ${jms.queue.new_queue}

${jms.queue.audit}

I'd then reconfigure the game server to send messages on the virtual queue
${jms.queue.game_events}, and they would be delivered both to my new
application and to the auditor.

Looking at the relevant section of the Spring XML configuration for the
game server, it looks like:

<!-- JMS Configuration -->

<bean id="jmsFailoverConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="failover:tcp://${jms.host}:${jms.port}"/>
<property name="copyMessageOnSend" value="false"/>
</bean>

<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://${jms.host}:${jms.port}"/>
<property name="copyMessageOnSend" value="false"/>
</bean>

<!-- JVM Dispatch Bridge Broker -->

<bean id="jvmBroker" class="org.apache.activemq.broker.BrokerService"
init-method="start" destroy-method="stop">
<property name="persistent" value="true"/>
<property name="dataDirectory" value="${broker.store}"/>
<property name="transportConnectorURIs">
<list>
<value>vm://localhost</value>
</list>
</property>
<property name="useJmx" value="false"/>
<property name="jmsBridgeConnectors">
<list>
<bean class="org.apache.activemq.network.jms.JmsQueueConnector">
<property name="outboundQueueConnectionFactory"
ref="jmsFailoverConnectionFactory"/>
<property name="outboundQueueBridges">
<list>
<!-- audit -->
<bean class="org.apache.activemq.network.jms.OutboundQueueBridge">
<constructor-arg value="${jms.queue.audit}"/>
</bean>
<!-- generic history -->
<bean class="org.apache.activemq.network.jms.OutboundQueueBridge">
<constructor-arg value="${jms.queue.generichistory}"/>
</bean>
</list>
</property>
</bean>
</list>
</property>
</bean>

<bean id="jvmConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://localhost"/>
<property name="copyMessageOnSend" value="false"/>
</bean>

<!-- Audit Factory -->

<bean id="auditFactory"
class="com.straycatstudios.wsc.server.framework.audit.JmsAuditFactory"
depends-on="jvmBroker">
<constructor-arg index="0">
<bean class="com.straycatstudios.wsc.common.spring.messaging.JmsSender">
<constructor-arg>
<bean class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="jvmConnectionFactory"/>
<property name="defaultDestinationName" value="${jms.queue.audit}"/>
<property name="messageConverter">
<bean
class="com.straycatstudios.wsc.server.framework.audit.EventMessageConverter">
<constructor-arg index="0" ref="simpleMessageConverter"/>
</bean>
</property>
</bean>
</constructor-arg>
</bean>
</constructor-arg>
</bean>

So it looks like it is using standard beans to set up the BrokerService and
other ActiveMQ stuff, instead of using the new style of embedding ActiveMQ
XML configuration inside the Spring XML. The JmsAuditFactory is the class
that does the sending, taking a JmsSender as constructor argument.

So finally, my question is: How I would go about setting up this composite
destination with a minimal amount of modifications to the Spring XML
configuration? The

The example at [1] only shows how to do it with the new approach of Spring
configuration, but I'd rather not do invasive things such as converting the
whole thing to the new embedded style, as I'm afraid I'd screw things up.

Very grateful for any tips/pointers on how to proceed. The full Spring
configuration of the game server is at http://paste.kde.org/789248/raw/ ,
in case the above paste is not enough (or mangled).

Best regards,
Elvis Stansvik

[1]
http://activemq.apache.org/virtual-destinations.html#VirtualDestinations-CompositeDestinations

Viewing all articles
Browse latest Browse all 5648

Trending Articles