I have a method:
public void sendMessage(MyJobDTO myJobDTO) {
jmsTemplate.send(new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
TextMessage message = null;
message = session.createTextMessage(myJobDTO.toString());
logger.info("Sending message...");
logger.info(message);
return message;
}
});
}
and my DTO's toString():
@Override
public String toString() {
return "{" +
"\"A\":" + "\"" + prop_a + "\"," +
"\"B\":" + "\"" + prop_b + "\"," +
"\"C\":" + "\"" + prop_c + "\"" +
"}";
}
I realise when the other application received the MQ message (using Spring Boot with JMS), the escape char \
appeared, causing errors. I tried to do replaceAll("\\\\", "")
but it couldnt find anything to replace. How can I get rid of the \
in the message sent to the MQ?