Spring与ActiveMQ(JMS)的整合说明

Posted by eDWARD at 15:37

  ActiveMQ是完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现,也是Apache Geronimo默认的JMS provider。

  ActiveMQ的网站:http://www.activemq.org

  使用ActiveMQ后,可以在普通Web服务器使用JMS功能,不依赖于特定的应用服务器。

    1. ActiveMQ 4.1-incubator-SNAPSHOT 与Spring 2.0 集成

    ActiveMQ4.1 响应Spring 2.0号召,支持了引入XML Schema namespace的简单配置语法,简化了配置的语句。

    1.1 引入ActiveMQ的XSD

    在ApplicationContext.xml(Spring的配置文件)中引入ActiveMQ的XML Scheam 配置文件),如下:
    (说明:由于ActiveMQ的那个XSD有部分错误,因此使用的是自行修改过的XSD,见”配置ClassPath中的scheam”小节)

    1.2 配置ClassPath中的schema

    在ClassPath 下面建立META-INF\spring.schemas 内容如下

    1.3 配置ActiveMQ embedded ActiveMQ Broker

    当spring初始化时候,ActiveMQ embedded Broker 就会启动了

    1.4 配置BookStore MDP

    配置ConnectionFactory,由于是embedded 所以URL为:vm://localhost

    配置Queue名字

    配置JmsTemplate

    配置MDP POJO

    补充说明

  1. 采用了自定义的MessageConverter,Producer能够直接发送POJO。
  2. 使用了Spring的DefaultMessageListenerContainer,MessageListenerAdapter, Consumer 不用实现MessageListener 接口。

Sphere: Related Content

Filed In 学习路上 | Study | Tags: , , , |

Your Comments.

Leave your own response

Leave a Reply.

Comment Form.

Fields denoted with a "*" are required. Your comment may require moderation, please be patient.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>




Your Reply.

Use the following link to trackback from your own site:
http://www.zhangzhang.net/articles/2007/01/10/spring-activemq-jms/trackback/

Spread the word.

Octopus supports RSS feed for this post RSS 2.0 , and Trackbacks from other blogs.


Technorati

  品位不凡,威严,略显高深,喜爱一切美丽的事物,易怒,固执,有些利己,但关心接近他的人。谦逊,但非常有野心,有才能,刻苦,是不甚令人满意的伴侣,朋友众多,树敌也多,是可以信赖的人。


bloglines google reader my yahoo
订阅数