Rabbitmq 简明教程

RabbitMQ - Test Application

Start the Producer Application

在 eclipse 中,右击 Producer.java 源文件,选择以 → 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 −

Enter message:

Start the Consumer Application

在 eclipse 中,右击 Consumer.java 源文件,选择以 → 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 −

Waiting for messages. To exit press CTRL+C

Send Message

在生产者控制台窗口中,键入 Hi 并按 enter 按钮发送消息。

In Producer console window, type Hi and press enter button to send the message.

Enter message:
Hi

Receive Message

在使用者控制台窗口中确认消息已收到。

Verify in Consumer console window, the message is received.

Waiting for messages. To exit press CTRL+C
Received = Hi

发送“退出”作为消息以终止生成窗口会话并终止客户端窗口会话。

Send Quit as message to terminate the producer window session and terminate client window session.

Verification

现在,在您的浏览器中打开 http://rabbitmq:15672/ 。它将要求输入凭据。使用 guest/guest 作为用户名/密码,它将加载 RabbitMQ 管理控制台,您可以在其中检查队列以查看状态。它将显示已排队和已交付的消息。

Now open http://rabbitmq:15672/ in your browser. It will ask for credentials. Use guest/guest as username/password and it will load the RabbitMQ admin console where you can check Queues to check the status. It will show messages enqueued and delivered.

rabbitmq queues