use*_*165 2 java activemq-classic jms publish-subscribe
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);
Run Code Online (Sandbox Code Playgroud)
clientId需要A 来唯一标识一个应用程序。在发布/订阅消息传递模式中使用持久订阅时,这是必须的。如您所知,消息传递提供者在脱机时会缓存发往持久订阅者应用程序的发布。当此类应用程序再次上线时,消息传递提供商必须进行标识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。为了验证它是相同的应用程序,消息传递提供程序将clientId应用程序的和clientId具有缓存的订阅信息的可用程序进行比较。
| 归档时间: |
|
| 查看次数: |
3139 次 |
| 最近记录: |