Skip to content

Instantly share code, notes, and snippets.

@bulain
Created July 19, 2011 07:15
Show Gist options
  • Save bulain/1091555 to your computer and use it in GitHub Desktop.
Save bulain/1091555 to your computer and use it in GitHub Desktop.
JMS spring config
##applicationContext-jms.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:jboss.properties" />
<!-- <property name="location" value="classpath:activemq.properties" /> -->
</bean>
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">${jms.factory.initial}</prop>
<prop key="java.naming.provider.url">${jms.provider.url}</prop>
<!-- ActiveMQ -->
<!-- <prop key="queue.demo.A">${jms.queue.name}</prop> -->
<!-- Jboss MQ -->
<prop key="java.naming.factory.url.pkgs">${jms.factory.url.pkgs}</prop>
</props>
</property>
</bean>
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>${jms.factory.name}</value>
</property>
<property name="jndiTemplate">
<ref local="jndiTemplate"></ref>
</property>
</bean>
<bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>${jms.queue.name}</value>
</property>
<property name="jndiTemplate">
<ref local="jndiTemplate"></ref>
</property>
</bean>
</beans>
##jboss.properties
jms.factory.initial=org.jnp.interfaces.NamingContextFactory
jms.provider.url=jnp://localhost:1099
jms.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
jms.factory.name=ConnectionFactory
jms.queue.name=queue/QueueA
##activemq.properties
jms.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
jms.provider.url=tcp://localhost:61616
jms.factory.url.pkgs=
jms.factory.name=ConnectionFactory
jms.queue.name=demo.A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment