22
ActiveMQ 作作honno 作作2008.8 Email: [email protected] 作作作作作作作作作作作作作作

Active Mq JMS

Embed Size (px)

DESCRIPTION

Apache Active MQ

Citation preview

ActiveMQ作者: honno时间: 2008.8Email: [email protected]目前研究和应用推广的开源项目:

概要ActiveMQ -JMS

- 特征 - 功能 - 实例

JMS 简介• ( 1 ) destination

• ( 2 ) product

• ( 3 ) consumer

• ( 4 ) broker

• ( 5 ) P2P,Pub/Sub

ActiveMQ 与 JMS

• JMS 是一种规范。

• ActiveMQ 是 JMS 规范的一种实现, MOM 。

ActiveMQ 架构图架构图

ActiveMQ 主要特征 特征 :• (1)JMS1.1,J2EE1.4• (2)J2EE servers(Tomcat,JBoss4,GlassFish,WebLogic…)• (3) 多语言客户端( Java,C,C++,C#,Ruby,PhP )• (4) 多种协议 (VM,TCP,SSL,UDP,multicast,JGroups…)• (5)Spring• (6)Ajax• (7)CXF,Axis• (8)REST• (9)Message Groups,Virtual Destinations,Wildcards,Composite Destinations• (10) 持久化 (journal,JDBC)• (11) 性能 (client-server,cluster,peer…)

ActiveMQ 功能介绍• 多种协议• 持久化• 安全• 群集• 监控• 其他

多种协议 URI: scheme:scheme-specific-part

• ( 1 ) VM vm://brokername • ( 2 ) TCP tcp://host:port • ( 3 ) SSL ssl://host:port • ( 4 ) HTTP http://host:port • ( 5 ) UDP udp://host:port

多种协议• ( 6 ) peer peer://group/brokername • ( 7 ) multicast multicast://IPAddress• ( 8 ) static static(list uris) • ( 9 ) failover failvoer(list uris)• ( 10 ) discovery discovery://host:port

持久化• 日志<journaledJDBC journalLogFiles="5"dataDirectory="../mq-data" />

• 数据库 包括: Derby,HSQL,MySQL,SQLServer,

Sybase,DB2,Oracle…<journaledJDBC dataSource="#mysql-ds"/>

安全• 认证 simpleAuthenticationPlugin

jaasAuthenticationPlugin

• 授权 authorizationPlugin

集群• Master/Slave

• Network of Brokers

监控• JMX

• Advisory Message

ActiveMQ 高级话题• Wildcards * 和 >• Composite Destinations

<compositeQueue ><forwardTo>

<queue … /><topic … />

</forwardTo></compositeQueue>

• Message Groups

ActiveMQ 入门实例• 实例说明:

• ActiveMQ 发送和异步接受文本类型消息的简单功能

broker

• 启动• BrokerService broker = new BrokerService();

        try {            broker.addConnector("tcp://localhost:61616");            broker.start();        } catch (InterruptedException e) {            e.printStackTrace();        } catch (Exception e) {            e.printStackTrace();        }

producer

• 发送 : 生产 10 个文本消息,并发送 .•  MessageProducer producer = • session.createProducer(destination);

            TextMessage message

• =session.createTextMessage(); for (int i = 0; i < 10; i++) {                message.setText("This is message " +

• (i + 1));                producer.send(message); }

consumer

• 接收• MessageConsumer consumer = session.c

reateConsumer(destination);            PrintlnUtil.println("Consumering Messages");            consumer.setMessageListener(this);

运行效果图

详细: http://www.opensourceforce.org/thread-249-1-1.html

更多资料• 更多关于 SOA,ESB,MQ 的相关资料见:• 开源力量

谢 谢