【发布时间】:2018-11-20 08:27:40
【问题描述】:
我正在尝试将 JSON 消息(对象)发布到 ActiveMQ 队列/主题。 目前我正在将 JSON 对象转换为字符串然后发布它。 但我不想把它转换成字符串。我不想把它转换成字符串而不是我想发送,因为它是 JSON 对象作为消息。
下面是我的代码
public void sendMessage(final JSONObject msg) {
logger.info("Producer sends---> " + msg);
jmsTemplate.send(destination, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
String s = msg.toString();
return session.createTextMessage(s);
// createTextMessage(msg);
}
});
}
【问题讨论】: