java监听mq消息_Java ActiveMQ 讲解(二)Spring ActiveMQ整合+注解消息监听

对于ActiveMQ消息的发送,原声的api操作繁琐,而且如果不进行二次封装,打开关闭会话以及各种创建操作也是够够的了。那么,Spring提供了一个很方便的去收发消息的框架,spring jms。整合Spring后,代码不仅变得非常优雅,而且易用性和扩展性更好。

废话不多说,直接开搞。

1. maven依赖

org.apache.xbean

xbean-spring

3.16

org.springframework

spring-jms

${springframework.version}

org.apache.activemq

activemq-all

${activemq.version}

2.命名空间引入

xmlns:jms="http://www.springframework.org/schema/jms"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.2.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.2.xsd

http://www.springframework.org/schema/jms

http://www.springframework.org/schema/jms/spring-jms-4.1.x

你可能感兴趣的:(java监听mq消息)