How do I change the filter on a subscription?

To do this, you need the subscription ID of the subscription you need to replace. The client sends that subscription ID and the new filter, and asks AMPS to replace the subscription.

The advantage of changing a filter rather than just creating a new subscription is that AMPS treats the replacement as atomic: for messages that match both the old and new filter, you are guaranteed not to lose messages or receive duplicate messages.

The exact syntax you use to do this differs depending on the language you're using. For example, in Java, you might use this command:

// subId is the command id from the previous subscribe command

                 "/order_status = 'new'",

This command replaces the previous subscription with a subscription to the topic named "the_topic", with a filter of "/order_status = 'new'".

Last updated