Skip to content

Instantly share code, notes, and snippets.

@alanhay
Forked from rponte/applicationContext-jms-test.xml
Last active October 11, 2015 11:37
Show Gist options
  • Select an option

  • Save alanhay/3852664 to your computer and use it in GitHub Desktop.

Select an option

Save alanhay/3852664 to your computer and use it in GitHub Desktop.
Embedded ActiveMQ with JMX on Spring 3.x #sample_spring_jms_config
<?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:jms="http://www.springframework.org/schema/jms" xmlns:p="http://www.springframework.org/schema/p"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- ActiveMQ Broker -->
<amq:broker id="test-broker" persistent="false" useJmx="true">
<amq:managementContext>
<amq:managementContext createConnector="true"/>
</amq:managementContext>
<amq:transportConnectors>
<amq:transportConnector uri="tcp://localhost:0" />
</amq:transportConnectors>
</amq:broker>
<!-- JMS ConnectionFactory to use -->
<!-- creates an activemq connection factory using the amq namespace -->
<amq:connectionFactory id="connectionFactory" brokerURL="vm://localhost:61616" />
<amq:queue id="destination" physicalName="myqueue" />
<!-- ********************************************* -->
<!-- Producers -->
<!-- ********************************************* -->
<!-- producer used only on test env -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate" primary="true">
<property name="connectionFactory" ref="connectionFactory" />
<property name="defaultDestination" ref="destination" />
<property name="receiveTimeout" value="3000"/> <!-- 3s -->
<property name="messageConverter" ref="pontosAContabilizarMessageConverter" />
</bean>
<!-- ********************************************* -->
<!-- Consumers -->
<!-- ********************************************* -->
<jms:listener-container container-type="default"
connection-factory="connectionFactory" acknowledge="transacted"
message-converter="pontosAContabilizarMessageConverter">
<jms:listener destination="myqueue" ref="contabilizadorDePontosListener" method="contabiliza" />
</jms:listener-container>
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment