Cookbook: Subscribe

This section presents common recipes for subscribing to a topic in AMPS using the Command or Message interfaces. This section provides information on how to configure the request to AMPS. You can adapt this information to your application and the specific interface you are using.

Command: subscribe

Basic Subscription

In its simplest form, a subscription needs only the topic to subscribe to.

Subscription with Options

In its simplest form, a subscription needs only the topic to subscribe to. To add options to the subscription, set the Options header on the Command.

Subscription with Select List

In its simplest form, a subscription needs only the topic to subscribe to. To use a select list with the subscription, set the Options header on the Command to the select list specifier.

Subscription with Content Filter

To provide a content filter on a subscription, set the Filter property on the command. The AMPS User Guide provides details on the filter syntax.

Conflated Subscription to a SOW Topic

To request conflation on a subscription, set the Options property on the command to specify the conflation interval. When the topic has a SOW (including a view or a conflated topic), there is no need to provide a conflation_key.

Conflated Subscription to a Topic with No SOW

To request conflation on a subscription, set the Options property on the command to specify the conflation interval. When the topic does not have a SOW, you must provide a conflation_key.

Bookmark Subscription

To create a bookmark subscription, set the Bookmark property on the command. The value of this property can be either a specific bookmark, a timestamp, or one of the client-provided constants. The AMPS User Guide provides details on creating timestamps. Notice that the MOST_RECENT constant tells the AMPS client to find the appropriate message in the client bookmark store and begin the subscription at that point. In this case, the client sends that bookmark value to AMPS. The Bookmark option is only supported for topics that are recorded in an AMPS transaction log.

Rate Controlled Bookmark Subscription

To create a bookmark subscription, set the Bookmark property on the command. The value of this property can be either a specific bookmark, a timestamp, or one of the client-provided constants. The AMPS User Guide provides details on creating timestamps. Notice that the MOST_RECENT constant tells the AMPS client to find the appropriate message in the client bookmark store and begin the subscription at that point. In this case, the client sends that bookmark value to AMPS. The Bookmark option is only supported for topics that are recorded in an AMPS transaction log.

To manage the message delivery rate to a bookmark subscription, set the rate option specifying the rate at which to replay messages.

Rate Controlled Bookmark Subscription with Maximum Gap

To create a bookmark subscription, set the Bookmark property on the command. The value of this property can be either a specific bookmark, a timestamp, or one of the client-provided constants. The AMPS User Guide provides details on creating timestamps. Notice that the MOST_RECENT constant tells the AMPS client to find the appropriate message in the client bookmark store and begin the subscription at that point. In this case, the client sends that bookmark value to AMPS. The Bookmark option is only supported for topics that are recorded in an AMPS transaction log.

The rate option specifies the rate at which to replay messages, while the rate_max_gap option specifies the maximum amount of time for AMPS to allow between messages.

Bookmark Subscription with Completed Acknowledgment

To create a bookmark subscription, set the Bookmark property on the command. The value of this property can be either a specific bookmark, a timestamp, or one of the client-provided constants. The AMPS User Guide provides details on creating timestamps. Notice that the MOST_RECENT constant tells the AMPS client to find the appropriate message in the client bookmark store and begin the subscription at that point. In this case, the client sends that bookmark value to AMPS. The Bookmark option is only supported for topics that are recorded in an AMPS transaction log.

To receive acknowledgment messages to a bookmark subscription, set the AckType on the command specifying the type of acknowledgments to receive. In this case, be sure to include the completed type.

Bookmark Subscription with Content Filter

To create a bookmark subscription, set the Bookmark property on the command. The property can be either a specific bookmark, a timestamp, or one of the client-provided constants. The AMPS User Guide provides details on creating timestamps. Notice that the MOST_RECENT constant tells the AMPS client to find the appropriate message in the client bookmark store and begin the subscription at that point. In this case, the client sends that bookmark value to AMPS.

To add a filter to a bookmark subscription, set the Filter property on the command. The AMPS User Guide provides details on the filter syntax.

Pausing a Bookmark Subscription

To pause a bookmark subscription, you must provide the subscription ID and the pause option on a subscribe command.

Resuming a Bookmark Subscription

To resume a bookmark subscription, you must provide the subscription ID and the resume option on a subscribe command.

Replacing the Filter on a Subscription

To replace the content filter on a subscription, provide the SubId of the subscription to be replaced, add the replace option, and set the Filter property on the command with the new filter. The AMPS User Guide provides details on the filter syntax.

Subscribing to a Queue and Requesting a max_backlog

To subscribe to a queue and request a max_backlog greater than 1, use the Options field of the subscribe command to set the requested max_backlog.

Last updated

Copyright 2013-2024 60East Technologies, Inc.