subscribe

The subscribe command is the primary way to retrieve messages from the AMPS processing stream. A client can issue a subscribe command on a topic to receive all published messages to that topic in the future. Additionally, content filtering can be used to choose which messages the client is interested in receiving.

Header Fields

Field

Description

Command

Command to be executed. Value: subscribe

Topic

Topic to place a subscription against.

AckType

Acknowledgment type for the given command.

Value is a comma separated list of one or more of the following: none, received, processed or completed.

Bookmark

A bookmark specifying the point in the transaction log at which to start the subscription.

If the topic provided is not recorded in a transaction log, AMPS enters the subscription without replaying messages. You can provide a single bookmark, or a comma-delimited list of bookmarks. When a list is provided, AMPS starts the subscription at the earliest bookmark in the list.

CommandId

If specified with an AMPS command requesting an acknowledgment message, all requested acknowledgment messages will contain the CommandId in the ack response header.

DataOnly

A Boolean value (true or false) which, if true, will send only raw data to subscriber for a matching publish message.

In the case where the message type is XML, the SOAP envelope will not be included.

Filter

A CDATA wrapped string, used as a content filter expression.

Options

A comma separated list of flags available to the subscribe command.

The Options Field table below describes the Options available for use in the subscribe command.

SendSubscriptionIds

Boolean (true or false) that tells if true requests AMPS to send subscription identifiers with a matched message.

SubscriptionId

The subscription ID for this command. When provided with a new subscription, this is the identifier that AMPS will use for the subscription.

When provided with the replace option, this field specifies the subscription to replace.

When provided with a pause or resume option, this field specifies the subscriptions to pause or resume.

For a new subscription, the AMPS clients will generate a subscription ID if one is not provided.

TopN

The maximum number of messages to provide from a bookmark subscription.

This parameter is only valid for replay from the transaction log.

This parameter is not valid if no bookmark is provided, if the provided bookmark is 0|1| (start from now), or if the command includes the live option.

Options Field

The following table contains a list of the Options available and their definitions when used in the AMPS subscribe command.

Option

Description

none

This is the default Options type.

bookmark

Specifies that the subscription should return bookmarks, if available, on each publish message. Bookmarks are only available if the topic that is subscribed to is recorded in the transaction log.

Notice that this option does not set the starting point for a bookmark subscription: use the Bookmark header for that purpose.

This option is not required to receive bookmarks for a bookmark subscription. Those subscriptions always include bookmarks on each publish message.

conflation=n

Specifies whether to conflate this subscription. The value provided can be a time interval, auto, or none.

When present and set to a value other than none, enables conflation for the subscription.

Can also be set to auto, which requests that AMPS attempt to determine an appropriate conflation interval based on client consumption.

Recognizes the same time specifiers used in the AMPS configuration file (for example, 100ms or 1s or 1m).

Default: none

conflation_key=[keys]

When conflation is enabled, specifies the fields to use to determine message uniqueness.

The format of this option is a comma-delimited list of XPath identifiers within brackets.

For example, to conflate based on the value of the /tickerId and /customerId within a message, the value of this option would be:

[/tickerId,/customerId].

Defaults to the SOW key fields for SOW topics. No default for non-SOW topics. This option is required for non-SOW topics.

This option is not valid with the oof option unless the keys provided are identical to the keys for the topic.

fully_durable

Tells AMPS to send messages to subscribing clients only after they have been persisted to the local transaction log and acknowledged by all downstream instances that use synchronous replication.

This option is only valid for bookmark subscriptions.

live

Tells AMPS to send messages to subscribing clients before they have been persisted to the transaction log.

This option is only valid for bookmark subscriptions.

max_backlog=n

When subscribing to a queue, the number of unacknowledged messages the client is willing to accept at a time.

AMPS will not exceed this number, but may choose a smaller number depending on the queue configuration.

non_regex_topic

Specifies that the topic name should be a literal match, even if the topic name contains regular expression characters.

no_sowkey

Tells AMPS not to send the AMPS-generated SowKey for messages.

oof

Not supported by this command type.

pause

Pause a bookmark subscription.

This option is only valid for bookmark subscriptions that do not use the live option. When this option is present, AMPS pauses the subscription or subscriptions provided in the SubId of the command.

rate=n

Set the maximum message delivery rate for a bookmark subscription.

This option is only valid for bookmark subscriptions that do not use the live option.

The rate can be specified as either the number of messages per second (for example, 1000), the number of bytes per second (for example, 100KB), or a multiple of the original replay rate (for example, 1.5X).

rate_max_gap=n

When entering a bookmark subscribe that is rate-limited, specify the maximum amount of time that AMPS will wait between messages.

replace

Replace the subscription associated with CmdId with another subscription.

resume

Resume a bookmark subscription.

This option is only valid for bookmark subscriptions that do not use the live option.

When this option is present, AMPS resumes the subscription or subscriptions provided in the SubId of the command.

select=[fields]

Specifies the fields to include in messages provided on this subscription.

The contents of this option are a comma-delimited list of inclusion specifiers.

send_keys

Not supported by this command type.

timestamp

AMPS will include a header with the time at which this instance of AMPS processed the incoming publish command for this message.

Returns

A subscribe command returns the following command types:

Command

Description

publish

A message published to AMPS.

oof

Returned when the oof option is requested on the command, the subscription is to a topic in the SOW, and the subscription is not a bookmark subscribe.

ack

Acknowledgments requested, as described in the following section.

It is possible to specify a processed acknowledgment be sent back to the client that issued the subscribe command. Within this processed acknowledgment, a client can get back the result of placing the subscription (success or failure) and the SubscriptionId, which uniquely identifies the subscription within AMPS. Keeping track of the SubscriptionId is useful for unsubscribing from subscriptions and issuing SOW queries.

The following table contains a list of the supported acknowledgment messages available to the subscribe command.

Acknowledgment

Description

none

No acknowledgment message is returned. This is the default behavior.

completed

Used by bookmark subscriptions to identify the point at which replay is completed.

When a bookmark is present on the subscribe request and this acknowledgment is requested, AMPS sends a completed acknowledgment message to indicate that bookmark replay is complete and the subscription has reached the point in the transaction log at which the subscribe command was received.

Messages delivered after the completed ack are from new publishes.

processed

AMPS has completed the work necessary to register the subscription.

When a bookmark is present and this acknowledgment is requested, this acknowledgment indicates that AMPS is about to begin replay.

persisted

When a bookmark is present and this acknowledgment is requested, AMPS periodically sends a persisted acknowledgment message to indicate the most recent bookmark in the server's transaction log.

received

The subscribe message has been received.

Errors

Any errors that occur during this command will be returned in the status of a processed acknowledgment and logged to the log file. Regardless of success or failure, the processed acknowledgment will only be returned if requested by including processed in the AckType field.

Last updated

Copyright 2013-2024 60East Technologies, Inc.