Spring MDP example


/ Published in: Java
Save to your folder(s)

A complete example of how to configure a Spring Message Driven Pojo (MDP) with a JBoss JMS Queue as its destination, this can be used with JMSTemplate.


Copy this code and paste it in your HTML
  1. <!-- our MDP -->
  2. <bean id="messageListener" class="server.mdpojos.MDPojo"/>
  3.  
  4. <!-- The Spring JMS container -->
  5. <bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
  6. <property name="connectionFactory" ref="connectionFactory"/>
  7. <property name="destination">
  8. <bean id="jmsDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
  9. <property name="jndiName" value="queue/DummyQueue"/>
  10. </bean>
  11. </property>
  12. <property name="messageListener" ref="messageListener"/>
  13. </bean>
  14.  
  15. <!-- A JNDI Template which is used to get a reference to the JBoss connection factory -->
  16. <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
  17. <property name="environment">
  18. <props>
  19. <prop key="java.naming.provider.url">localhost:1099</prop>
  20. <prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop>
  21. <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
  22. </props>
  23. </property>
  24. </bean>
  25.  
  26. <!-- The JBoss connection factory -->
  27. <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
  28. <property name="jndiTemplate">
  29. <ref bean="jndiTemplate"/>
  30. </property>
  31. <property name="jndiName">
  32. <value>ConnectionFactory</value>
  33. </property>
  34. </bean>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.