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

1

2

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;
        }
    });
Ahmadahmar answered 8/8, 2020 at 10:37 Comment(1)
I tried doing this using a 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 calling message.setStringProperty("MessageId", "A generated Message ID"); without success.Coelacanth
C
0

The Service Bus team is considering this feature request.

Coelacanth answered 24/8, 2022 at 9:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.