消息发送问题

This commit is contained in:
2026-04-16 15:29:00 +08:00
parent 7511cb0ba8
commit 5e8712a93b

View File

@@ -7,7 +7,6 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
@@ -161,21 +160,21 @@ public class RabbitPublisher {
public void sendOtherPrintMsg(Long shopId, Object data, String printType) {
String exchange = activeProfile + "-" + RabbitConstants.Exchange.CASH_EXCHANGE;
String queueName = activeProfile + "-" + RabbitConstants.Queue.OTHER_PRINT_QUEUE;
Map<String, Object> msg = new HashMap<>();
msg.put("shopId", shopId);
msg.put("data", data);
msg.put("printTypeEnum", printType);
rabbitTemplate.convertAndSend(exchange, queueName, JSONObject.toJSONString(msg));
JSONObject jsonObject = new JSONObject();
jsonObject.put("shopId", shopId);
jsonObject.put("data", data);
jsonObject.put("printTypeEnum", printType);
rabbitTemplate.convertAndSend(exchange, queueName, jsonObject.toString());
}
public void sendOtherPrintLocalMsg(Long shopId, String printType, Long dataId) {
String exchange = activeProfile + "-" + RabbitConstants.Exchange.CASH_EXCHANGE;
String queueName = activeProfile + "-" + RabbitConstants.Queue.OTHER_PRINT_LOCAL_QUEUE;
Map<String, Object> msg = new HashMap<>();
msg.put("shopId", shopId);
msg.put("dataId", dataId);
msg.put("printType", printType);
rabbitTemplate.convertAndSend(exchange, queueName, msg);
JSONObject jsonObject = new JSONObject();
jsonObject.put("shopId", shopId);
jsonObject.put("dataId", dataId);
jsonObject.put("printType", printType);
rabbitTemplate.convertAndSend(exchange, queueName, jsonObject.toString());
}
}