Message Id gets overridden when sending message to Azure service bus using Spring JMS. Because of this reason, duplicate detection is not working as expected. I have read JMS documentation where it's been said that JMSMessageId can't be set by producer, it is reserved by JMS for internal usage. Now Problem here is how can I set MessageID to detect duplicate message.
Any help on this please?? Sample code that I have tried is mentioned below.
jmsTemplate.send(topicName, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
BytesMessage message = session.createBytesMessage();
message.setJMSMessageID("0111111-order");
message.setJMSCorrelationID("0111111");
message.writeBytes(strJsonOrder.getBytes());
return message;
}
});
MessagePostProcessor
, but it's also not working for me.jmsTemplate.convertAndSend(queue, event, message -> { message.setJMSMessageID("A generated Message ID"); return message; });
I also tried callingmessage.setStringProperty("MessageId", "A generated Message ID");
without success. – Coelacanth