1. Windows 版本
•OS Name:Microsoft Windows 10 Enterprise•Version:10.0.19043 Build 19043
2. 安装
2.1 安装和配置 Open JDK
•下载 Open JDK[1]•解压缩:openjdk-17_windows-x64_bin.zip•设置环境变量 JAVA_HOME,例如:C:\software\java\openjdk•设置环境变量 PATH,增加一条,%JAVA_HOME%\bin•检查安装是否正确:打开一个 cmd 窗口,输入 java -version
$ java -version
openjdk 17 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
2.2 安装和配置 Maven
•下载 Maven[2]•解压缩:apache-maven-3.8.2-bin.zip• 设置环境变量 M2_HOME,例如:C:\software\apache\maven•设置环境变量 PATH,增加一条,%M2_HOME%\bin•设置环境变量 MAVEN_OPTS,例如:-Xms512m -Xmx1024m•检查安装是否正确:打开 cmd 命令窗口,mvn -version
$ mvn -version
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: C:\software\apache\maven
Java version: 17, vendor: Oracle Corporation, runtime: C:\software\java\openjdk
Default locale: en_US, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
2.3 安装和配置 ActiveMQ
•下载 ActiveMQ[3] ,找到“ActiveMQ "Classic"”,点击 “Download Latest”,下载最新的 ActiveMQ。•解压缩:apache-activemq-5.16.3-bin.zip
3. 启动
进入安装目录,例如:C:\software\apache\activemq
$ bin\activemq start
Java Runtime: Oracle Corporation 17 C:\software\java\openjdk
Heap sizes: current=1048576k free=1041918k max=1048576k
JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=C:\software\apache\activemq\bin\..\conf\login.config -Dactivemq.classpath=C:\software\apache\activemq\bin\..\conf;C:\software\apache\activemq\bin\../conf;C:\software\apache\activemq\bin\../conf; -Dactivemq.home=C:\software\apache\activemq\bin\.. -Dactivemq.base=C:\software\apache\activemq\bin\.. -Dactivemq.conf=C:\software\apache\activemq\bin\..\conf -Dactivemq.data=C:\software\apache\activemq\bin\..\data -Djava.io.tmpdir=C:\software\apache\activemq\bin\..\data\tmp
Extensions classpath:
[C:\software\apache\activemq\bin\..\lib,C:\software\apache\activemq\bin\..\lib\camel,C:\software\apache\activemq\bin\..\lib\optional,C:\software\apache\activemq\bin\..\lib\web,C:\software\apache\activemq\bin\..\lib\extra]
ACTIVEMQ_HOME: C:\software\apache\activemq\bin\..
ACTIVEMQ_BASE: C:\software\apache\activemq\bin\..
ACTIVEMQ_CONF: C:\software\apache\activemq\bin\..\conf
ACTIVEMQ_DATA: C:\software\apache\activemq\bin\..\data
Loading message broker from: xbean:activemq.xml
INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@6aeb35e6: startup date [Sun Sep 26 18:24:51 CST 2021]; root of context hierarchy
INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[C:\software\apache\activemq\bin\..\data\kahadb]
INFO | KahaDB is version 7
INFO | PListStore:[C:\software\apache\activemq\bin\..\data\localhost\tmp_storage] started
INFO | Apache ActiveMQ 5.16.3 (localhost, ID:MININT-OJ4LF63-49939-1632651892011-0:1) is starting
INFO | Listening for connections at: tcp://MININT-OJ4LF63:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600
INFO | Connector openwire started
INFO | Listening for connections at: amqp://MININT-OJ4LF63:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600
INFO | Connector amqp started
INFO | Listening for connections at: stomp://MININT-OJ4LF63:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600
INFO | Connector stomp started
INFO | Listening for connections at: mqtt://MININT-OJ4LF63:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600
INFO | Connector mqtt started
INFO | Starting Jetty server
INFO | Creating Jetty connector
WARN | ServletContext@o.e.j.s.ServletContextHandler@5a6482a9{/,null,STARTING} has uncovered http methods for path:
INFO | Listening for connections at ws://MININT-OJ4LF63:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600
INFO | Connector ws started
INFO | Apache ActiveMQ 5.16.3 (localhost, ID:MININT-OJ4LF63-49939-1632651892011-0:1) started
INFO | For help or more information please see: http://activemq.apache.org
INFO | ActiveMQ WebConsole available at http://127.0.0.1:8161/
INFO | ActiveMQ Jolokia REST API available at http://127.0.0.1:8161/api/jolokia/
问题:默认启动时,报告
ERROR | Failed to start Apache ActiveMQ (localhost, ID:MININT-OJ4LF63-58726-1632647895865-0:1) java.io.IOException: Transport Connector could not be registered in JMX: java.io.IOException: Failed to bind to server socket: tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600 due to: java.net.BindException: Address already in use: bind
错误,无法正常启动。经过分析,发现是 Internet Connection Sharing (ICS) 服务和 ActiveMQ 服务冲突,将 ICS 服务 stop 后,再启动 ActiveMQ 就正常了。
$ netstat -an|find "61616"
TCP 0.0.0.0:61616 0.0.0.0:0 LISTENING
TCP [::]:61616 [::]:0 LISTENING
重要:ActiveMQ 默认的端口是 61616。
4. 访问管理控制台
•URL: http://127.0.0.1:8161/admin/•Login: admin•Passwort: admin
说明:默认的用户名/口令是 admin/admin。你可以在 conf/jetty-realm.properties 文件中指定。
创建一个 Queue,并发送一条消息
•Navigate to “Queues”•Add a queue name “test-queue” and click create•Send test message by clicking on “Send to”
创建一个 Topic,并发送一条消息
•Navigate to “Topics”•Add a queue name “test-topic” and click create•Send test message by clicking on “Send to”
5. 日志
日志文件位于:[activemq_install_dir]/data/activemq.log。
6. 停止
$ bin\activemq stop
Java Runtime: Oracle Corporation 17 C:\software\java\openjdk
Heap sizes: current=1048576k free=1041918k max=1048576k
JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=C:\software\apache\activemq\bin\..\conf\login.config -Dactivemq.classpath=C:\software\apache\activemq\bin\..\conf;C:\software\apache\activemq\bin\../conf;C:\software\apache\activemq\bin\../conf; -Dactivemq.home=C:\software\apache\activemq\bin\.. -Dactivemq.base=C:\software\apache\activemq\bin\.. -Dactivemq.conf=C:\software\apache\activemq\bin\..\conf -Dactivemq.data=C:\software\apache\activemq\bin\..\data -Djava.io.tmpdir=C:\software\apache\activemq\bin\..\data\tmp
Extensions classpath:
[C:\software\apache\activemq\bin\..\lib,C:\software\apache\activemq\bin\..\lib\camel,C:\software\apache\activemq\bin\..\lib\optional,C:\software\apache\activemq\bin\..\lib\web,C:\software\apache\activemq\bin\..\lib\extra]
ACTIVEMQ_HOME: C:\software\apache\activemq\bin\..
ACTIVEMQ_BASE: C:\software\apache\activemq\bin\..
ACTIVEMQ_CONF: C:\software\apache\activemq\bin\..\conf
ACTIVEMQ_DATA: C:\software\apache\activemq\bin\..\data
useJmxServiceUrl Found JMS Url: service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2ZXIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc4AAtVbmljYXN0UmVmMgAADTE5Mi4xNjguMC4xMDMAANZKEw5SWbeDKFeEC5xOAAABfCHASfCAAQB4
Connecting to pid: 34168
Stopping broker: localhost
References
[1]
Open JDK: https://openjdk.java.net/[2]
Maven: https://maven.apache.org/download.cgi[3]
ActiveMQ: http://activemq.apache.org/




