What's the difference between CommandId, QueryId, and SubId?

A simple way to look at the differences is that clients submit a CommandId with their commands. AMPS then uses that CommandId when it needs to refer to the command later on.

Here's a quick breakdown from the point of view of the AMPS server:

  • CommandId identifies a specific command. Clients provide this on commands to AMPS, and AMPS returns it in the ack messages for that command. The CommandId is also provided on the query results and subscription results to indicate the command that ran the query and/or registered the subscription, as follows:

  • QueryId is returned on SOW results, and provides the CommandId of the SOW query command or the QueryId specified on the SOW query. For messages returned from a sow command, only the QueryId is set on the message.

  • SubIds are returned on messages received from a subscription, and is the CommandId of the subscribe command that entered the subscription, or the SubId specified on the subscribe command. Notice that, when modifying a subscription with the replace option, you use the SubId of the subscription to tell AMPS which subscription to replace. For messages returned from a sow_and_subscribe, the SubId is set on the group_begin and group_end messages and the publish messages.

The AMPS clients fill in a CommandId where necessary if one is not provided, and return that CommandId for use in correlating later messages to and from AMPS.

In the AMPS HAClients, bookmark subscribe commands use a SubId to locate and resume subscriptions: in this case, to correctly resume a subscription, the AMPS HAClient interfaces request that the application provide a SubId. The client then uses that SubId to resume the subscription as necessary, and handles populating the CommandId properly for a bookmark subscribe.

We document these header fields in more detail in the AMPS Command Reference, available from the 60East website.

Last updated