Apache Activemq 简明教程
Apache ActiveMQ - Test Application
Start ActiveMQ Server
现在,我们来启动 ActiveMQ 服务器。转到文件夹 F:/ → Apache → apache-activemq-5.16.4/bin ,并输入以下命令。
Now let’s start the ActiveMQ Server. Go to the folder F:/ → Apache → apache-activemq-5.16.4/bin and type the following command.
Output
您将看到类似的输出,ActiveMQ 将开始运行。
You’ll see the similar output and ActiveMQ will start running.
...
INFO | Apache ActiveMQ 5.16.4 (localhost, ID:DESKTOP-86KD9FC-52669-1645860020983-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/
Start the Producer Application
在 eclipse 中,右键单击 Producer.java 源码,然后选择“Run As”(作为)> “Java 应用程序”。生产者应用程序将开始运行,您将看到如下输出:
In eclipse, right click on the Producer.java source, and select Run As > Java Application. Producer application will start running and you’ll see the output as follows −
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Enter message:
Start the Consumer Application
在 eclipse 中,右键单击 Consumer.java 源码,然后选择“Run As”(作为)> “Java 应用程序”。使用者应用程序将开始运行,您将看到如下输出:
In eclipse, right click on the Consumer.java source, and select Run As > Java Application. Consumer application will start running and you’ll see the output as follows −
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Send Message
在生产者控制台窗口中,键入 Hi 并按 enter 按钮发送消息。
In Producer console window, type Hi and press enter button to send the message.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Enter message:
Hi
Receive Message
在使用者控制台窗口中确认消息已收到。
Verify in Consumer console window, the message is received.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Received = Hi
发送退出作为消息以终止生产者和使用者控制台窗口会话。
Send Quit as message to terminate both producer and consumer console window sessions.
Verification
现在在浏览器中打开 http://127.0.0.1:8161/admin/ 。它会询问凭据。使用 admin/admin 作为用户名/密码,它将加载 ActiveMQ 管理控制台,您可以在其中查看队列以查看状态。它将显示已入队和已发送的 2 条消息。
Now open http://127.0.0.1:8161/admin/ in your browser. It will ask for credentials. Use admin/admin as username/password and it will load the ActiveMQ admin console where you can check Queues to check the status. It will show 2 messages enqueued and delivered.