embedded ActiveMQ Broker
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/corehttp://activemq.apache.org/schema/core/activemq-core.xsd">
<!--letscreateanembeddedActiveMQBroker-->
<amq:brokeruseJmx="false"persistent="false">
<amq:transportConnectors>
<amq:transportConnectoruri="tcp://localhost:0"/>
</amq:transportConnectors>
</amq:broker>
<!--ActiveMQdestinationstouse-->
<amq:queueid="destination"physicalname="org.apache.activemq.spring.Test.spring.embedded"/>
<!--JMSConnectionFactorytouse,configuringtheembeddedbrokerusingXML-->
<amq:connectionFactoryid="jmsFactory"brokerURL="vm://localhost"/>
<!--SpringJMSTemplate-->
<beanid="myJmsTemplate"class="org.springframework.jms.core.JmsTemplate">
<propertyname="connectionFactory">
<!--letswrapinapooltoavoidcreatingaconnectionpersend-->
<beanclass="org.springframework.jms.connection.SingleConnectionFactory">
<propertyname="targetConnectionFactory">
<reflocal="jmsFactory"/>
</property>
</bean>
</property>
</bean>
<beanid="consumerJmsTemplate"class="org.springframework.jms.core.JmsTemplate">
<propertyname="connectionFactory"ref="jmsFactory"/>
</bean>
<!--asamplePOJOwhichusesaSpringJmsTemplate-->
<beanid="producer"class="org.apache.activemq.spring.SpringProducer">
<propertyname="template">
<refbean="myJmsTemplate"></ref>
</property>
<propertyname="destination">
<refbean="destination"/>
</property>
<propertyname="messageCount">
<value>10</value>
</property>
</bean>
<!--asamplePOJOconsumer-->
<beanid="consumer"class="org.apache.activemq.spring.SpringConsumer">
<propertyname="template"ref="consumerJmsTemplate"/>
<propertyname="destination"ref="destination"/>
</bean>
</beans>