| | |
| | |
|
| | | public ModuleA(String QUEUENAME) {
|
| | | QUEUE_NAME = QUEUENAME;
|
| | | receiver = new RabbitMQUtils(); // 实例化 RabbitMQUtils 对象
|
| | | // 实例化 RabbitMQUtils 对象
|
| | | receiver = new RabbitMQUtils();
|
| | | }
|
| | |
|
| | | public static void main(String[] argv) throws Exception {
|
| | |
| | | // String message = "Your message to send666";
|
| | | // String messageId = "5"; // 消息ID
|
| | | // receiver.sendMessageWithId(QUEUE_NAME, message, messageId); // 调用 sendMessageWithId 方法发送消息
|
| | | receiver.sendMessageWithId("hangzhou2", "Hello RabbitMQ!", "1");
|
| | | receiver.sendMessageWithId("hangzhou2", "Another message", "2");
|
| | | receiver.sendMessageWithId("hangzhou2", "Yet another message", "1"); // 这条消息会打印重复消息的错误信息
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Hello RabbitMQ!", "1");
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Another message", "2");
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Another message", "3");
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Another message", "4");
|
| | | RabbitMQUtils.sendMessageWithId("hangzhou2", "Another message", "5");
|
| | | // receiver.sendMessageWithId("hangzhou2", "Yet another message", "1"); // 这条消息会打印重复消息的错误信息
|
| | |
|
| | | }
|
| | | }
|