wang
2024-03-26 ea073afc6b4bc758990ac60f5e33254d1143272c
UnLoadGlassModule/src/main/java/com/mes/service/ModuleA.java
New file
@@ -0,0 +1,25 @@
package com.mes.service;
import com.mes.common.RabbitMQUtils;
public class ModuleA {
    private static String QUEUE_NAME = "hangzhou2";
    private static RabbitMQUtils receiver;
    public ModuleA(String QUEUENAME) {
        QUEUE_NAME = QUEUENAME;
        receiver = new RabbitMQUtils(); // 实例化 RabbitMQUtils 对象
    }
    public static void main(String[] argv) throws Exception {
//        ModuleA moduleA = new ModuleA("hangzhou2"); // 实例化 ModuleA 对象
//        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"); // 这条消息会打印重复消息的错误信息
    }
}