Can a client have more than one subscription at a time?

A single client can have more than one subscription active at the same time. AMPS delivers messages for all active subscriptions to the client.

The AMPS clients deliver messages for each subscription to the message handler you provide when you create the subscription. This can be the same message handler for all subscriptions, or a different message handler for each subscription. In the event that the subscriptions overlap (that is, where a given message matches more than one subscription), AMPS will deliver the message to the client application once, indicating which subscriptions the message applies to. The AMPS client libraries will then deliver the message once to each subscription.

It's important to remember, though, that AMPS treats each subscribe command as a new subscription. For example, consider a case where you subscribe to the orders topic with a filter "/region IN ('US', 'FR', 'UK')" and then subscribe to the orders topic with a filter "/region IN ('BR')". Your client receives messages for all of those regions, on two different subscriptions.

If you want to change the filter on an existing subscription, see the developer's guide for replace subscription, or the FAQ item on changing a subscription.

Last updated