[azureservicebus - How to set MessageId using JMS in Azure Service Bus

Viewed 184

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;
        }
    });
1 Answers
Related