为JMS发布者/使用者设置clientID的目的是什么? [英] What's the Purpose of setting the clientID for JMS publisher / consumer?
问题描述
我了解在为持久主题编写jms主题订户时,我需要设置clientId和订阅名称。
但是在以下情况下设置clientID的目的是什么?发布主题?我见过有人甚至为发布者/使用者设置了客户端ID,但是没有人解释为什么要这样做。
ConnectionFactory conFactory = this.getConnectionFactory();
连接连接= conFactory.createConnection();
connection.setClientID( WHATS_MY_PURPOSE); //为什么从消费者/发布者发布主题时我们需要clientID
connection.start();
MessageProducer生产者= session.createProducer(destination);
A clientId
是唯一标识应用程序所必需的。在发布/订阅消息传递模式中使用永久订阅时,这是必须的。如您所知,消息传递提供者在脱机时会缓存发往持久订阅者应用程序的发布。当此类应用程序再次上线时,消息传递提供者必须确定 OK,这与创建持久订阅但由于某种原因而消失的同一应用程序相同。现在又回来了。因此,让我传递在此应用程序消失后发布的所有消息
。为了验证它是同一应用程序,消息传递提供程序将应用程序的 clientId
与具有缓存的订阅信息的 clientId
进行比较。 / p>
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
. To verify it's the same application, messaging provider compares the clientId
of the application with clientId
available with cached subscription information.
这篇关于为JMS发布者/使用者设置clientID的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!