Can long-term subscriptions withstand restarting the client?

If I use a long-term subscription, can I restart my client and resend the subscription without losing messages? (Suppose my client doesn’t unsubscribe in any way. Let's say it just crashes).

Let me clarify. JMS 1.1 Spec says the following:

9.3.3.2 Reconnecting to a topic using a strong subscription

/* Reconnect to a durable subscription */ session.createDurableSubscriber(newsFeedTopic, "mySubscription"); 

However, there are some important limitations:

  • The client must be tied to the same connection.
  • The name of the recipient and the subscription must be the same.
  • If a message selector has been specified, it must also be the same.

This part of the “same connection” interests me. It is not clear what “same” means in this context.

+4
source share
2 answers

In the specification, see 4.3, where it is mentioned that the Connection object can contain a unique identifier for the client and 4.3.2, which indicates ...

The purpose of a customer identifier is to associate a connection and its objects with a state maintained by the supplier on behalf of the customer. By definition, a client’s state identified by a client identifier can be “used by only one client at a time. The JMS provider must prevent clients from simultaneously using it.

Thus, it is understood here that a long-term subscription contains a unique identifier, so that when you re-subscribe an application, it can be linked to the correct state store where messages were queued in its absence. Since the preferred way to do this is to encode the identifier in the connection object for the client, the specification directs you to reconnect using the same connection, but in this case means that the object is not the same (to use WMQ terminology).

Of course, you do not need a managed object; an application can generate a connection dynamically. In this case, you will need to set the same client identifier for it for subsequent signatures.

+2
source

If there is no active subscriber for a long-term subscription, JMS saves the subscription messages until they are received by the subscriber, or until they expire, or until the long-term subscription is deleted. This allows subscriber applications to disconnect from the JMS provider for periods of time, and then reconnect to the provider and process messages that were published during their absence.

+1
source

Source: https://habr.com/ru/post/1316334/


All Articles