官网地址 http://activemq.apache.org/
.net客户端支持 首页:http://activemq.apache.org/nms/ 下载:http://activemq.apache.org/nms/download.html
java客户端支持
使用maven直接支持
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.13.3</version>
</dependency>
当然可以选择适用自己的子包, activemq-client, activemq-broker, activemq-xx-store etc.
ActiveMQ使用了Apache的Camel框架,Camel是一个轻量级的集成框架,它实现了所有的EIP(Enterprise Integration Patterns 企业集成模式)
具体使用见自己的业务场景
代表一个运行ActiveMQ的节点
前支持的有:VM Transport、TCP Transport、NIO Transport、SSL Transport、Peer Transport、UDP Transport、Multicast Transport、HTTP and HTTPS Transport、WebSockets Transport、Failover Transport、Fanout Transport、Discovery Transport、ZeroConf Transport等
VM Transport:允许客户端和Broker直接在VM内部通信,采用的连接不是Socket连接,而是方法的直接调用,从而避免了网络开销,但是应用场景仅限于客户端和Broker在同一JVM环境下;
TCP Transport:客户端通过TCP Socket连接到远程Broker。配置语法:tcp://hostname:port?transportOptions
HTTP and HTTPS Transport:允许客户端使用REST或者Ajax的方式进行连接。这意味着可以直接使用Javascript向ActiveMQ发送消息。
WebSockets Transport:允许客户端通过HTML5标准的WebSockets方式连接到Broker。
Failover Transport:青龙系统MQ采用的就是这种连接方式。这种方式具备自动重新连接的机制,工作在其他Transport的上层,用于建立可靠的传输。允许配置任意多个的URI,该机制将会自动选择其中的一个URI来尝试连接。配置语法:failover:(tcp://localhost:61616,tcp://localhost:61617,…..)?transportOptions
Fanout Transport:主要适用于生产消息发向多个代理。如果多个代理出现环路,可能造成消费者接收重复的消息。所以,使用该协议时,最好将消息发送给多个不相连接的代理。
默认是KahaDB(本地文件系统,5.3之前推荐使用)、JDBC(支持各种数据库,长久持久化推荐使用)、LevelDB(本地文件系统,5.9之后推荐使用) ,具体见三种持久化方式笔记
Shared File System Master Slave、JDBC Master Slave、Replicated LevelDB Store
官网地址:http://activemq.apache.org/masterslave.html
具体见笔记,配置及使用
帮助文档:http://activemq.apache.org/using-activemq-4.html
我们还没有那么牛逼,去改源代码,然后重新编译安装。我们只安装人家编译好的二进制程序,具体如下。
Download the activemq zipped tarball file to the Unix machine, using either a browser or a tool, i.e., wget, scp, ftp, etc. for example: (see Download -> “The latest stable release”)
wget http://activemq.apache.org/path/tofile/apache-activemq-x.x.x-bin.tar.gz
Extract the files from the zipped tarball into a directory of your choice. For example:
cd [activemq_install_dir]
tar zxvf activemq-x.x.x-bin.tar.gz
Starting ActiveMQ
From a command shell, change to the installation directory and run ActiveMQ as a foregroud process:
cd [activemq_install_dir]/bin
./activemq console
From a command shell, change to the installation directory and run ActiveMQ as a daemon process:
cd [activemq_install_dir]/bin
./activemq start
# 以下是输出
INFO: Loading '/usr/local/apache-activemq-5.13.3//bin/env'
INFO: Using java '/usr/local/jdk1.7.0_60/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/usr/local/apache-activemq-5.13.3//data/activemq.pid' (pid '1687')
更多启动方式,请看链接:
http://127.0.0.1:8161/admin/
,我的测试环境为http://192.168.226.71:8161/admin/
,用户名密码为admin/admintest_001
,点击create,可以看到多了一个队列[activemq_install_dir]/data/activemq.log
,可以看到如下类似输出
2016-06-20 14:45:20,616 | INFO | Apache ActiveMQ 5.13.3 (localhost, ID:localhost.localdomain-54957-1466405120141-0:1) started | org.apache.activemq.broker.BrokerService | main
# netstat -anpt | grep 61616
tcp 0 0 :::61616 :::* LISTEN 1687/java
http://127.0.0.1:8161/admin/
,用户名密码为admin/admin,可以在conf/jetty-real.properties
中配置docs/WebConsole-README.txt
cd [activemq_install_dir]/bin
./activemq stop
可选配置项 | 描述 | 使用方式 | 语法 |
---|---|---|---|
xbean | 通过指定xbean-spring的xml配置文件来启动 | activemq start xbean:sample.xml | http://activemq.apache.org/xml-configuration.html |
broker | 通过指定URI来启动 | activemq start broker:*** | broker:(transportURI,network:networkURI)/brokerName?brokerOptions,http://activemq.apache.org/broker-uri.html |
properties | 通过指定一个properties文件来启动 | activemq start properties:sample.properties | http://activemq.apache.org/broker-properties-uri.html |