返回顶部

收藏

Spring MDP (Message Driven Pojo) 配置实例

更多

使用 JBoss 的 JMS

xml代码

<!-- our MDP -->
<bean id="messageListener" class="server.mdpojos.MDPojo"/>

<!-- The Spring JMS container -->
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
  <property name="connectionFactory" ref="connectionFactory"/>
  <property name="destination">
    <bean id="jmsDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
       <property name="jndiName" value="queue/DummyQueue"/>
     </bean>
   </property>
  <property name="messageListener" ref="messageListener"/>
</bean>

<!-- A JNDI Template which is used to get a reference to the JBoss connection factory -->
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
   <property name="environment">
     <props>
      <prop key="java.naming.provider.url">localhost:1099</prop>
      <prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop>
      <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
     </props>
   </property>
</bean>

<!-- The JBoss connection factory -->
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiTemplate">
     <ref bean="jndiTemplate"/>
   </property>
   <property name="jndiName">
     <value>ConnectionFactory</value>
   </property>
</bean>

标签:JMS,Spring,java

收藏

0人收藏

支持

0

反对

0

发表评论