简体   繁体   中英

What's the Purpose of setting the clientID for JMS publisher / consumer?

I understand that i need to set the clientId and subscription name when writing the jms topic subscriber for my durable topics.

But Whats the purpose of setting the clientID when publishing the TOPIC ? I have seen people setting the client Id even for publisher / consumer, but no one explained that why it is required.

ConnectionFactory conFactory =  this.getConnectionFactory();
Connection connection = conFactory.createConnection();

connection.setClientID("WHATS_MY_PURPOSE"); // Why do we need clientID while publishing the TOPIC from consumer / publisher

connection.start();
MessageProducer producer = session.createProducer(destination);

A clientId is required to uniquely identify an application. It's a must when using a durable subscription in Pub/Sub messaging pattern. As you might be aware, a messaging provider caches publications destined for durable subscriber applications when they are off-line. When such applications come on-line again, a messaging provider has to identify OK, this is the same application that created a durable subscription but went away for reason. Now it has come back. So let me deliver all messages that were published when this application was away OK, this is the same application that created a durable subscription but went away for reason. Now it has come back. So let me deliver all messages that were published when this application was away OK, this is the same application that created a durable subscription but went away for reason. Now it has come back. So let me deliver all messages that were published when this application was away . To verify it's the same application, messaging provider compares the clientId of the application with clientId available with cached subscription information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM