[jboss-user] [JBoss Messaging] - Re: Embedded server - how to create JMS Topic?

Leos.Bitto do-not-reply at jboss.com
Mon Jul 13 05:31:27 EDT 2009


"rkapur123" wrote : Hi Leos.bitto
  | 
  | I have jboss SOA 4.3 ESB which has Jboss Messaging as messaging provoder.
  | 
  | Using Spring framework's MDP (message driven pojo) - I want to listen on "sampleQueue". As per springframework 2.5 guide - MDP is a simple class which implements javax.jms.MessageListener onMessage().
  | 

I do not use any support for JMS from Spring, because my trust in their JMS code vanished when I found out how terribly inefficient is their JmsTemplate. So I have studied the JMS 1.1 specification and wrote the necessarry code myself - it was not difficult, and I got a code which performs much better.

"rkapur123" wrote : 
  | I have the class and specified the following in applicationContext.xml file
  | 
  | 
  |   |     <bean id="messageListener" class="com.acme.SpringMDP" />
  |   | 
  |   |     <bean id="listenerContainer"
  |   | 		class="org.springframework.jms.listener.DefaultMessageListenerContainer">
  |   | 		<property name="concurrentConsumers" value="5" />
  |   | 		<property name="destination" ref="destination" />
  |   | 		<property name="connectionFactory" ref="connectionFactory" />
  |   | 		<property name="messageListener" ref="messageListener" />
  |   | 	</bean>
  |   | 
  | 
  | but how should I define "connectionFactory" and "destination" in spring context file. 
  | 

There are more possibilities, but the most versatile one seems to be to use JNDI - that actually makes your code compatible with most JMS providers, not only JBoss Messaging. Check the chapter 5.3. JNDI configuration of the JBoss Messaging documentation and use something like this (not tested):


  |   <bean name="jbmJndiEnv">
  |     <props>
  |       <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
  |       <prop key="java.naming.provider.url">jnp://myhost:1099</prop>
  |       <prop key="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</prop>
  |     </props>
  |   </property>
  | 
  |   <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
  |     <property name="jndiEnvironment" ref="jbmJndiEnv" />
  |     <property name="lookupOnStartup" value="false"/>
  |     <property name="proxyInterface" value="javax.jms.ConnectionFactory"/>
  |     <property name="jndiName" value="ConnectionFactory" />
  |   </bean>
  | 
  |   <bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
  |     <property name="jndiEnvironment" ref="jbmJndiEnv" />
  |     <property name="lookupOnStartup" value="false"/>
  |     <property name="proxyInterface" value="javax.jms.Destination" />
  |     <property name="jndiName" value="/queue/ExampleQueue" />
  |   </bean>
  | 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4243200#4243200

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4243200



More information about the jboss-user mailing list