Friday, January 18, 2008

spring jms quickstart infrastructure configuration

using spring JMS and ApacheMQ you can set up messaging capabilities within your application, even outside of a jee container.

here is an xml sample representing the beans that set up the jms infrastructure:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://embedded?broker.persistent=false"/>
</bean>

<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="queue.request"></constructor-arg>
</bean>

<bean id="confirmationQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="queue.confirmation"></constructor-arg>
</bean>

</beans>

the latter beans are queues, which can be named and coded appropriately and you can have as many as you need. queues are required for messages to be sent on.

the broker url also needs adjusting to represent your infrastructure, however this embedded broker can be used for development and testing.

0 Comments:

Post a Comment

<< Home