Code, JavaEE

Refined ActiveMQ Spring Context Xml

This is a refined version of the spring context xml.

</pre>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:p="http://www.springframework.org/schema/p"
 xmlns:jms="http://www.springframework.org/schema/jms"
 xmlns:amq="http://activemq.apache.org/schema/core"
 xmlns:jee="http://www.springframework.org/schema/jee"
 xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.2.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">

<!-- enable annotations -->
 <context:annotation-config />

<context:component-scan base-package="com.davidkingenterprise" />

<bean id="applicationContextProvider"
 class="com.davidkingenterprise.config.ApplicationContextProvider" />

<!-- active mq connection factory -->
 <bean id="amqConnectionFactory"
 class="org.apache.activemq.ActiveMQConnectionFactory"
 p:brokerURL="tcp://localhost:61616"
 p:userName="admin"
 p:password="admin" />

<bean id="cachedConnectionFactory"
 class="org.springframework.jms.connection.CachingConnectionFactory"
 p:targetConnectionFactory-ref="amqConnectionFactory"
 p:sessionCacheSize="10" />

<!-- queue destination -->
 <amq:queue id="principlesRequestQueue" physicalName="Principles.Request"/>
 <amq:queue id="principlesResponseQueue" physicalName="Principles.Response"/>

<!-- jms template instance -->
 <bean id="producerTemplate"
 class="org.springframework.jms.core.JmsTemplate"
 p:connectionFactory-ref="cachedConnectionFactory"
 p:defaultDestination-ref="principlesRequestQueue" />

<!-- jms queue listener, response to requests -->
 <bean id="principlesListener" class="com.davidkingenterprise.messaging.TaskMessageListener" />

<!-- jms listener container -->
 <jms:listener-container
 container-type="default"
 connection-factory="cachedConnectionFactory"
 acknowledge="auto"
 concurrency="10-50">
 <jms:listener destination="Principles.Request"
 response-destination="Principles.Response"
 ref="principlesListener" />
 </jms:listener-container>
</beans>
<pre>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s