ActiveMQ实战(一)-入门篇

时间:2021-11-23 20:34:06

概述

Apache ActiveMQ是一个非常流行的,能力强劲的开源消息总线服,ActiveMQ 完全支持JMS1.1和J2EE 1.4规范。

官方介绍如下

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.
Apache ActiveMQ is released under the Apache 2.0 License.

Features

  • Supports a variety of Cross Language Clients and Protocols from Java, C, C++, C#, Ruby, Perl, Python, PHP

    • OpenWire for high performance clients in Java, C, C++, C#
    • Stomp support so that clients can be written easily in C, Ruby, Perl, Python, PHP, ActionScript/Flash, Smalltalk to talk to ActiveMQ as well as any other popular Message Broker
    • AMQP v1.0 support
    • MQTT v3.1 support allowing for connections in an IoT environment.
  • full support for the Enterprise Integration Patterns both in the JMS client and the Message Broker

  • Supports many advanced features such as Message Groups, Virtual Destinations, Wildcards and Composite Destinations

  • Fully supports JMS 1.1 and J2EE 1.4 with support for transient, persistent, transactional and XA messaging

  • Spring Support so that ActiveMQ can be easily embedded into Spring applications and configured using Spring’s XML configuration mechanism

  • Tested inside popular J2EE servers such as TomEE, Geronimo, JBoss, GlassFish and WebLogic

    • Includes JCA 1.5 resource adaptors for inbound & outbound messaging so that ActiveMQ should auto-deploy in any J2EE 1.4 compliant server
  • Supports pluggable transport protocols such as in-VM, TCP, SSL, NIO, UDP, multicast, JGroups and JXTA transports

  • Supports very fast persistence using JDBC along with a high performance journal

  • Designed for high performance clustering, client-server, peer based communication

  • REST API to provide technology agnostic and language neutral web based API to messaging

  • Ajax to support web streaming support to web browsers using pure DHTML, allowing web browsers to be part of the messaging fabric

  • CXF and Axis Support so that ActiveMQ can be easily dropped into either of these web service stacks to provide reliable messaging

  • Can be used as an in memory JMS provider, ideal for unit testing JMS

安装&部署

Windows

1.下载
到ActiveMQ官网下载最新release版本,官网提供有windows版本和linux版本。
ActiveMQ实战(一)-入门篇

2.解压缩
解压下载的apache-activemq-5.13.2-bin.zip,得到解压后的目录结构如下

ActiveMQ实战(一)-入门篇

3.启动
启动ActiveMQ之前,请先确保JDK已安装并配置好环境变量,进入bin录下:
ActiveMQ实战(一)-入门篇

有win32和win64两个文件夹,这2个文件夹分别对应windows32位和windows64位操作系统的启动脚本。

由于我安装是 Win10 64位系统,就进入win64目录,会看到如下目录结构:
ActiveMQ实战(一)-入门篇

其中activemq.bat便是启动脚本,双击启动。
ActiveMQ实战(一)-入门篇

Linux

1.下载
Download -> “The latest stable release”

> wget http://activemq.apache.org/path/tofile/apache-activemq-5.13.2-bin.tar.gz

2.解压缩

> tar zxvf activemq-5.13.2-bin.tar.gz

3.启动
a) run ActiveMQ as a foregroud process:

> cd activemq-5.13.2/bin
> ./activemq console

b) run ActiveMQ as a daemon process:

> cd [activemq_install_dir]/bin
> ./activemq start

验证安装是否成功

启动成功后在浏览器地址栏输入:http://localhost:8161/admin,会要求输入用户名密码,默认用户名密码为admin、admin,这个用户名密码是在conf/users.properties中配置的。输入用户名密码后便可看到如下图的ActiveMQ控制台界面了
ActiveMQ实战(一)-入门篇

OK,到此ActiveMQ已经启动了。

参考资料:
https://activemq.apache.org/getting-started.html