Rabbitmq 简明教程
RabbitMQ - Test Application Topic
Start the Publisher Application
在 eclipse 中,鼠标右键单击 Publisher.java 源,然后选择以 Java 应用程序运行。Publisher 应用程序将开始运行,您会看到如下所示的输出:
In eclipse, right click on the Publisher.java source, and select Run As → Java Application. Publisher application will start running and you’ll see the output as follows −
Enter message:
Start the Subscriber Application
在 eclipse 中,鼠标右键单击 Subscriber.java 源,然后选择以 Java 应用程序运行。Subscriber 应用程序将开始运行,您会看到如下所示的输出:
In eclipse, right click on the Subscriber.java source, and select Run As → Java Application. Subscriber application will start running and you’ll see the output as follows −
Waiting for messages. To exit press CTRL+C
Start another Subscriber Application
在 eclipse 中,再次鼠标右键单击 Subscriber.java 源,然后选择以 Java 应用程序运行。另一个 Subscriber 应用程序将开始运行,您会看到如下所示的输出:
In eclipse, again right click on the Subscriber.java source, and select Run As → Java Application. Another Subscriber application will start running and you’ll see the output as follows −
Waiting for messages. To exit press CTRL+C
Send Message
在 Publisher 控制台窗口中,输入 Hi 并按回车键以发送消息。
In Publisher console window, type Hi and press enter button to send the message.
Enter message:
Hi
Receive Message
在 Subscriber 控制台窗口中验证,消息在每个窗口中都能收到。
Verify in Subscriber console windows, the message is received in each window.
Received = Hi
发送退出作为消息以终止所有发布者和订阅者控制台窗口会话。
Send Quit as message to terminate all publisher and subscriber console window sessions.
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 and Exchanges to check the status of messages delivered and bindings.