资源准备
登录官网下载安装包,https://activemq.apache.org/activemq-5014004-release
一、安装启动
1.1、准备java环境
yum install java-1.8.0-openjdk-devel
或者
yum install java-11-openjdk
1.2、安装ActiveMQ所需软件包
#下载软件包到/opt目录,解压后安装
[root@bogon opt]$ wget https://archive.apache.org/dist/activemq/5.14.4/apache-activemq-5.14.4-bin.tar.gz -P /opt
[root@bogon opt]$ cd /opt
[root@bogon opt]$ tar -xvf apache-activemq-5.14.4-bin.tar.gz
[root@bogon opt]$ cd apache-activemq-5.14.4/ && ll
总用量 15888
-rwxr-xr-x 1 root root 16209408 2月 27 2017 activemq-all-5.14.4.jar
drwxr-xr-x 5 root root 147 2月 23 11:42 bin
drwxr-xr-x 2 root root 4096 2月 23 11:42 conf
drwxr-xr-x 3 root root 77 2月 23 11:43 data
drwxr-xr-x 2 root root 76 2月 23 11:42 docs
drwxr-xr-x 7 root root 71 2月 27 2017 examples
drwxr-xr-x 6 root root 4096 2月 23 11:42 lib
-rw-r--r-- 1 root root 40580 2月 27 2017 LICENSE
-rw-r--r-- 1 root root 3334 2月 27 2017 NOTICE
-rw-r--r-- 1 root root 2610 2月 27 2017 README.txt
drwxr-xr-x 4 root root 137 2月 23 11:43 tmp
drwxr-xr-x 6 root root 95 2月 23 11:42 webapps
drwxr-xr-x 3 root root 18 2月 23 11:42 webapps-demo
1.3、启动ActiveMQ相关服务
3.1.启动服务
[root@bogon apache-activemq-5.14.4]$ bin/activemq start
INFO: Loading '/opt/apache-activemq-5.14.4//bin/env'
INFO: Using java '/usr/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/opt/apache-activemq-5.14.4//data/activemq.pid' (pid '307934')
3.2.查看服务状态
[root@bogon apache-activemq-5.14.4]$ bin/activemq status
INFO: Loading '/opt/apache-activemq-5.14.4//bin/env'
INFO: Using java '/usr/bin/java'
ActiveMQ is running (pid '307934')
二、测试
2.1、 用程序自带的jar包生产消息
[root@bogon apache-activemq-5.14.4]# java -jar activemq-all-5.14.4.jar producer
INFO | Connecting to URL: failover://tcp://localhost:61616 (null:null)
INFO | Producing messages to queue://TEST
INFO | Using persistent messages
INFO | Sleeping between sends 0 ms
INFO | Running 1 parallel threads
INFO | Successfully connected to tcp://localhost:61616
INFO | producer-1 Started to calculate elapsed time ...
INFO | producer-1 Produced: 1000 messages
INFO | producer-1 Elapsed time in second : 2 s
INFO | producer-1 Elapsed time in milli second : 2897 milli seconds
2.2、用程序自带的jar包消费信息
[root@localhost apache-activemq-5.14.4]# java -jar activemq-all-5.14.4.jar consumer
INFO | Connecting to URL: failover://tcp://localhost:61616 (null:null)
INFO | Consuming queue://TEST
INFO | Sleeping between receives 0 ms
INFO | Running 1 parallel threads
INFO | Successfully connected to tcp://localhost:61616
INFO | consumer-1 wait until 1000 messages are consumed
INFO | consumer-1 Received test message: 0
INFO | consumer-1 Received test message: 1
INFO | consumer-1 Received test message: 2
INFO | consumer-1 Received test message: 3
INFO | consumer-1 Received test message: 4
INFO | consumer-1 Received test message: 5
INFO | consumer-1 Received test message: 6
INFO | consumer-1 Received test message: 7
INFO | consumer-1 Received test message: 8
INFO | consumer-1 Received test message: 9
INFO | consumer-1 Received test message: 10
.............................................
.............................................
INFO | consumer-1 Received test message: 990
INFO | consumer-1 Received test message: 991
INFO | consumer-1 Received test message: 992
INFO | consumer-1 Received test message: 993
INFO | consumer-1 Received test message: 994
INFO | consumer-1 Received test message: 995
INFO | consumer-1 Received test message: 996
INFO | consumer-1 Received test message: 997
INFO | consumer-1 Received test message: 998
INFO | consumer-1 Received test message: 999
INFO | consumer-1 Consumed: 1000 messages
INFO | consumer-1 Consumer thread finished
2.3、登录控制台
http://localhost:8161/admin
用户名:admin
密码:admin