On 6/26/20 1:19 PM, akabhishek1 wrote:
HI Team,

We are using ServiceBus Broker, and using qpid-jms-client-0.45.0 to publish
message. ServiceBus provides facility to 'ignore duplicate messages' with
the help of MessageID.

For achieving this requirement - We need to set JMS message ID while
publishing the message. At this moment, i have not found any way to set
custom messageID via qpid JMS client. I tried with below options but that
doesn't help.

JmsMessageProducer messageProducer = (JmsMessageProducer)
session.createProducer(destination);
messageProducer.setDisableMessageID(true);
TextMessage textMessage = session.createTextMessage("Hello World");
((AmqpJmsMessageFacade) ((JmsMessage)
textMessage).getFacade()).setMessageId("AKQWS:9d678sdfsdsds");

The JMSMessageID is set by the JMS provider. It cannot be set by the client as per the JMS specification. The JMS spec /does/ guarantee the uniqueness of the JMSMessageID. Section 3.4.3 of both the JMS 1.1 & 2 specifications says the following in regards to this uniqueness quality.

"A |JMSMessageID| is a |String| value which should function as a unique key for identifying messages in a historical repository. The exact scope of uniqueness is provider defined. It should at least cover all messages for a specific installation of a provider where an installation is some connected set of message routers."

The specification also calls out that calling setJMSMessageID is reserved for provider use and that any user set value on an outgoing message will be lost as read from the JMS Message API documentation:

"This method is for use by JMS providers only to set this field when a message is sent. This message cannot be used by clients to configure the message ID. This method is public to allow a JMS provider to set this field when sending a message whose implementation is not its own."

Attempting to work around this quality is prevented by the normal functioning of the JMS MessageProducer implementation in the client which will manage the state of this field as per specification guidelines.

Qpid JMS does provide a means of providing your own Message ID via a policy object (JmsMessageIDPolicy) that can be set on the JmsConnectionFactory.

        CustomJmsMessageIDPolicy custom = new CustomJmsMessageIDPolicy();
        JmsConnectionFactory factory = new JmsConnectionFactory(uri);
        factory.setMessageIDPolicy(custom);

This is an advanced feature that requires care in its use and requires that you take ownership of any side effects caused by doing so.



I did testing with Microsoft JAVA SDK
(com.microsoft.azure:azure-servicebus:1.2.11), and i am able to achieve this
requirement via setting MessageID.

Could you please provide any way to set MessageID.

Regards,
Abhishek Kumar



--
Sent from: http://qpid.2158936.n2.nabble.com/Apache-Qpid-users-f2158936.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org
For additional commands, e-mail: users-h...@qpid.apache.org


--
Tim Bish

Reply via email to