1.核心配置文件(applicationContext-jms-producer.xml生产者)?
5.12.0
<!-- 1.配置activemq工厂对象 -->
<bean id="targetConnectionFactory" class="ActiveMQConnectionFactory的全限定名">
<property name="brokerURL" value="tcp://119.23.64.69:61616" />
</bean>
<!-- 2.配置spring提供的整合activeMq连接工厂
-->
<bean id="connectionFactory" class="org.framework.jms.connection.SingleConnnectionFactory">
<property name="targetConnectionFactory" ref="targetConnectionFactory"/>
</bean>
<!-- -->
<!-- 3.配置jmsTemplate -->
<bean id="" class="org.framework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory"/>
</bean>
<!-- 4.配置Destination目的地(queue 和 topic)-->
<bean id="" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="pingyougou_queue_delete" />
</bean>
<bean id="" class="org.apache.activemq.command.ActiveMQQueue">
<construtor-arg value="pingyougou_queue_topic_delete"/>
</bean>
<!-- 配置监听 -->
<bean id="" class="LocalMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" value="第四步配置中的一个" />
<property name="messageListener" value="新建一个监听类实现MessageListener" />
</bean>
2.核心配置文件(applicationContext-jms-consumer.xml消费者)?
<bean id="connectionFactory" class="org.framework.jms.connection.SingleConnectionFactory">
<property name="targetConnectionFactory" ref="targetConnectionFactory" />
</bean>
<bean id="jmsTemplate" class="org.framework.jms.core.JmsTemplate" >
<property name="connectionFactory" ref="connectionFactory" />
</bean>
<bean id="queue_任意名称" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="队列的名称"/>
</bean>
<bean id="topic_任意名称" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg value="发布订阅的名称"/>
</bean>