Skip to main content

spark subscribe

The subscribe command allows the AMPS spark CLI to register an interest in incoming messages to a topic, so that they will be delivered in real time. Similar to the sow command, the subscribe command supports regular expression topic matching and content filtering, which allow a subscription to be very specific when looking for data as it is published to AMPS. Unlike the sow command, a subscription can be placed on a topic which does not have a persistent SOW cache configured. This allows a subscribe command to be very flexible in the messages it can be configured to receive.

Common Options - spark subscribe​

OptionDefinition

server

(required)

AMPS server to connect to.

topic

(required)

Topic to subscribe to.
ack

Enable acknowledgments when receiving from a queue.

Notice that, when this option is provided, AMPS spark CLI acknowledges messages from the queue, signaling to AMPS that the message has been fully processed. (See the chapter on Message Queues in the AMPS server documentation for more information.)

backlogRequest a max_backlog of greater than 1 when receiving from a queue. (See the chapter on Message Queues in this guide for more information.)
copyPublishes records to the secondary server specified.
deltaUse delta subscription (sends a delta_subscribe command to AMPS).
filterContent filter to use.
format

Optional format used for displaying messages. May contain literal separator characters mixed with format tags.

Allowed tags are:

{bookmark}, {command}, {correlation_id}, {data}, {expiration}, {lease_period}, {length}, {sowkey}, {user_id}, {timestamp}, {topic}

Notice that not all headers may be available on every request, depending on the options provided to the request. See the AMPS Command Reference for details.

Example: -format "{command}:{data}"

proto

Protocol to use.

In this release, AMPS spark CLI supports amps, fix, nvfix and xml.

Defaults to amps. AMPS spark CLI also supports json as a synonym for amps in this release.

secure

(applies to SSL connections)

Specifies whether to use an SSL-secured connection (tcps URI scheme).

Values: false/0/no or true/1/yes

Default: false

typeFor protocols and transports that accept multiple message types on a given transport, specifies the message type to use.
uriopts

Custom connection URI parameters to be passed in the URI query string.

For example:

tcp_nodelay=true&tcp_sndbuf=8192

urischeme

(applies to SSL connections)

Allows a custom URI scheme to be specified.

When both secure and urischeme are specified, urischeme takes precedence.

Examples​

%> ./spark subscribe -server localhost:9007 -topic chaos \
-type json -filter "/name = 'cup'"

{ "name" : "cup", "place" : "cupboard" }

The example above places a subscription on the chaos topic with a filter that will only return results for messages where /name = 'cup'. If we place this subscription before a matching message is published, then we will get results similar to above.

For the full range of options, run spark help subscribe. See AMPS spark CLI Authentication and AMPS spark CLI Support for TCPS for shared connection settings.