ActiveMQ讲义.ppt
- 文档编号:11657476
- 上传时间:2023-06-01
- 格式:PPT
- 页数:22
- 大小:232.50KB
ActiveMQ讲义.ppt
《ActiveMQ讲义.ppt》由会员分享,可在线阅读,更多相关《ActiveMQ讲义.ppt(22页珍藏版)》请在冰点文库上搜索。
ActiveMQ讲义,孙勇卫2009-02-06,一、ActiveMQ介绍,ActiveMQ是什么?
ActiveMQ是Apache出品,最流行的,能力强劲的开源消息总线。
ActiveMQ是一个完全支持JMS1.1和J2EE1.4规范的JMSProvider实现,ActiveMQ特性列表,1.多种语言和协议编写客户端。
语言:
Java,C,C+,C#,Ruby,Perl,Python,PHP。
应用协议:
OpenWire,StompREST,WSNotification,XMPP,AMQP2.完全支持JMS1.1和J2EE1.4规范(持久化,XA消息,事务)3.对Spring的支持,ActiveMQ可以很容易内嵌到使用Spring的系统里面去,而且也支持Spring2.0的特性4.通过了常见J2EE服务器(如Geronimo,JBoss4,GlassFish,WebLogic)的测试,其中通过JCA1.5resourceadaptors的配置,可以让ActiveMQ可以自动的部署到任何兼容J2EE1.4商业服务器上5.支持多种传送协议:
in-VM,TCP,SSL,NIO,UDP,JGroups,JXTA6.支持通过JDBC和journal提供高速的消息持久化7.从设计上保证了高性能的集群,客户端-服务器,点对点8.支持Ajax9.支持与Axis的整合10.可以很容易得调用内嵌JMSprovider,进行测试,一、ActiveMQ介绍二、ActiveMQ安装配置,ActiveMQ安装,一、安装在http:
/activemq.apache.org/download.html下载5.2.0发行包,解压到需要安装ActiveMQ的文件夹(假设该文件夹为/path/),记为/path/activemq。
unix环境activemq文件夹需要执行权限,执行如下命令chmod-R755/path/activemq,ActiveMQ安装,二、启动window环境运行/path/activemq/bin/activemq.batunix环境运行/path/activemq/bin/activemq,ActiveMQ安装,三、测试ActiveMQ默认使用的TCP连接端口是61616,通过查看该端口的信息可以测试ActiveMQ是否成功启动window环境运行netstat-an|find61616unix环境运行netstat-an|grep61616,ActiveMQ安装,监控ActiveMQ5.2版本默认启动时,启动了内置的jetty服务器,提供一个demo应用和用于监控ActiveMQ的admin应用。
admin:
http:
/127.0.0.1:
8161/admin/demo:
http:
/127.0.0.1:
8161/demo/点击demo应用中的“Marketdatapublisher”,就会发一些测试的消息。
转到admin页面的topicsmenu下面,可以看到消息在增长。
一、ActiveMQ介绍二、ActiveMQ安装配置三、ActiveMQ架构,ActiveMQ架构,一、ActiveMQ介绍二、ActiveMQ安装配置三、ActiveMQ架构四、ActiveMQ消息模式,ActiveMQ消息模式,一、Point-to-Point(PTP,点对点)ActiveMQ的PTP模式通过消息队列(Queue)实现。
消息由一个JMS客户机(Producer)发送到服务器上的一个队列(Queue)。
而另一个JMS客户机(Consumer)则可以访问这个队列,并从该服务器获取这条消息。
ActiveMQ消息模式,二、Publich/Subscribe(发布/订阅者)ActiveMQ的Publich/Subscribe模式通过消息主题(Topic)实现。
消息由一个JMS客户机(Producer)发布到服务器上的一个主题(Topic),可有多个订阅者(Consumer)去访问该消息。
消息将一直维持在主题中,直到这个主题的所有订阅者都取走了该消息的一个副本。
消息也包括了一个参数,用于定义了该消息的耐久性(它能够在服务器上等待订阅者多长时间)。
一、ActiveMQ介绍二、ActiveMQ安装配置三、ActiveMQ架构四、ActiveMQ消息模式五、ActiveMQCMS,ActiveMQCMS,CMS(standsforC+MessagingService)isaJMS-likeAPIforC+forinterfacingwithMessageBrokerssuchasApacheActiveMQ.,一、ActiveMQ介绍二、ActiveMQ安装配置三、ActiveMQ架构四、ActiveMQ消息模式五、ActiveMQCMS六、CMS入门实例,CMS入门实例,实例说明:
ActiveMQ发送和异步接受文本类型消息的简单功能,采用PTP模式,Producer,/CreateaConnectionFactoryConnectionFactory*connectionFactory=ConnectionFactory:
createCMSConnectionFactory(brokerURI);/CreateaConnectionconnection=connectionFactory-createConnection();connection-start();/freethefactory,wearedonewithit.deleteconnectionFactory;/CreateaSessionsession=connection-createSession(Session:
AUTO_ACKNOWLEDGE);/Createthedestination(Queue)destination=session-createQueue(destURI);/CreateaMessageProducerfromtheSessiontotheTopicorQueueproducer=session-createProducer(destination);producer-setDeliveryMode(DeliveryMode:
NON_PERSISTENT);/Createamessagesstringtext=(string)Helloworld!
“;for(unsignedintix=0;ixcreateTextMessage(text);message-setIntProperty(Integer,ix);/Telltheproducertosendthemessageprintf(Sentmessage#%dn,ix+1);producer-send(message);deletemessage;,Consumer,建立一个类,继承自ExceptionListener,启动消费者代码/CreateaConnectionFactoryConnectionFactory*connectionFactory=ConnectionFactory:
createCMSConnectionFactory(brokerURI);/CreateaConnectionconnection=connectionFactory-createConnection();deleteconnectionFactory;connection-start();connection-setExceptionListener(this);/CreateaSessionsession=connection-createSession(Session:
AUTO_ACKNOWLEDGE);/Createthedestination(Queue)destination=session-createQueue(destURI);/CreateaMessageConsumerfromtheSessiontotheTopicorQueueconsumer=session-createConsumer(destination);consumer-setMessageListener(this);,Consumer,接收消息,重载onMessage函数virtualvoidonMessage(constMessage*message)staticintcount=0;trycount+;constTextMessage*textMessage=dynamic_cast(message);stringtext=;if(textMessage!
=NULL)text=textMessage-getText();elsetext=NOTATEXTMESSAGE!
;printf(Message#%dReceived:
%sn,count,text.c_str();catch(CMSException,谢谢,
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ActiveMQ 讲义
![提示](https://static.bingdoc.com/images/bang_tan.gif)