消息发送问题

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