A brief introduction and installation of JMS-ActiveMQ (2)

 

Article from: http://www.aijava.cn/13512.html

 

In the real enterprise, the application of message communication has always been very hot, and it plays a special role in the enterprise application of J2EE, so it is very necessary to study it.

This blog post introduces an open source implementation of JMS - ActiveMQ. ActiveMQ is an easy-to-use messaging middleware.

message middleware

Let's briefly introduce the message middleware, just have a basic understanding of it, the message middleware (MOM: Message Orient middleware).

Message middleware has many uses and advantages: 
1. Transfer data from one application to another, or from one software module to another; 
2. Responsible for establishing network communication channels for reliable data send. 
3. Ensure that the data is not retransmitted or lost 
4. Can realize cross-platform operation, and can provide data transmission services for software integration technicians on different operating systems

SQM

First of all, I will briefly introduce MQ. The English name of MQ is MessageQueue. The Chinese name is also the message queue that everyone uses. Why do you use it? To put it bluntly, it is a container for receiving and forwarding messages, which can be used for message push.

Let's enter our topic today and introduce ActiveMQ to you:

ActiveMQ

Brief overview of ActiveMQ

Apache ActiveMQ ™ is the most popular and powerful open source messaging and Integration Patterns server.
Apache ActiveMQ is fast, supports many Cross Language Clients and Protocols, comes with easy to use Enterprise Integration Patterns and many advanced features while fully supporting JMS 1.1 and J2EE 1.4.

ActiveMQ是由Apache出品的,一款最流行的,能力强劲的开源消息总线。ActiveMQ是一个完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现,它非常快速,支持多种语言的客户端和协议,而且可以非常容易的嵌入到企业的应用环境中,并有许多高级功能。

下面我们下载一个版本,玩一玩。

下载ActiveMQ

官方网站:http://activemq.apache.org/ 
现在ActiveMQ最新的版本是5.11.1,下载挺简单的,就不再截图了。

运行ActiveMQ服务

  1. 下载,解压缩 
    大家现在好之后,将apache-activemq-5.11.1-bin.zip解压缩,我们可以看到它的整体目录结构: 


    从它的目录来说,还是很简单的: 
    • bin存放的是脚本文件
    • conf存放的是基本配置文件
    • data存放的是日志文件
    • docs存放的是说明文档
    • examples存放的是简单的实例
    • lib存放的是activemq所需jar包
    • webapps用于存放项目的目录
  2. 启动ActiveMQ 
    我们了解activemq的基本目录,下面我们运行一下activemq服务,双击bin目录下的activemq.bat脚本文件或运行自己电脑版本下的activemq.bat,就可以看下图的效果。 

从上图我们可以看到activemq的存放地址,以及浏览器要访问的地址. 
3. 测试

ActiveMQ默认使用的TCP连接端口是61616, 通过查看该端口的信息可以测试ActiveMQ是否成功启动 netstat -an|find “61616”

C:\Documents and Settings\Administrator>netstat -an|find "61616" 
TCP     0.0.0.0:61616     0.0.0.0:0       LISTENING

4. 监控 
ActiveMQ默认启动时,启动了内置的jetty服务器,提供一个用于监控ActiveMQ的admin应用。 
admin:http://127.0.0.1:8161/admin/

用户名和密码都是admin



5. 至此,服务端启动完毕

停止服务器,只需要按着Ctrl+Shift+C,之后输入y即可。

我们简单说说ActiveMQ特性,网上很多,只是为了保证博文的完整。

ActiveMQ特性列表

  1. 多种语言和协议编写客户端。语言: Java, C, C++, C#, Ruby, Perl, Python, PHP。应用协议: OpenWire,Stomp REST,WS Notification,XMPP,AMQP
  2. 完全支持JMS1.1和J2EE 1.4规范 (持久化,XA消息,事务)
  3. 对Spring的支持,ActiveMQ可以很容易内嵌到使用Spring的系统里面去,而且也支持Spring2.0的特性
  4. 通过了常见J2EE服务器(如 Geronimo,JBoss 4, GlassFish,WebLogic)的测试,其中通过JCA 1.5 resource adaptors的配置,可以让ActiveMQ可以自动的部署到任何兼容J2EE 1.4 商业服务器上
  5. 支持多种传送协议:in-VM,TCP,SSL,NIO,UDP,JGroups,JXTA
  6. 支持通过JDBC和journal提供高速的消息持久化
  7. 从设计上保证了高性能的集群,客户端-服务器,点对点
  8. 支持Ajax
  9. 支持与Axis的整合
  10. 可以很容易得调用内嵌JMS provider,进行测试

什么情况下使用ActiveMQ?

  1. 多个项目之间集成 
    (1) 跨平台 
    (2) 多语言 
    (3) 多项目
  2. 降低系统间模块的耦合度,解耦 
    (1) 软件扩展性
  3. 系统前后端隔离 
    (1) 前后端隔离,屏蔽高安全区

其实ActiveMQ的应用还有很多,大家可以上网查查,不再一一举例。

总结

ActiveMQ并不难,具有很多的优势。

下篇博文,我们做一个简单实例,真正的体会一把ActiveMQ的魅力。

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326776819&siteId=291194637