Skip to main content

spark sow_and_subscribe

The sow_and_subscribe command is a combination of the sow command and the subscribe command. When a sow_and_subscribe is requested, AMPS will first return all messages which match the query and are stored in the SOW. Once this has completed, all messages which match the subscription will then be sent to the client as they update the topic.

The sow_and_subscribe is a powerful tool to use when it is necessary to examine both the contents of the SOW, and the live subscription stream.

Common Options - spark sow_and_subscribe​

OptionDefinition

server

(required)

AMPS server to connect to.

topic

(required)

Topic to query and subscribe to.
batchsizeBatch size to use during query.
copyPublishes records to the secondary server specified.
deltaRequest delta for subscriptions (sends a sow_and_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}"

orderbyAn expression that AMPS will use to order the SOW query results.
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

topnRequest AMPS to limit the SOW query results to the first N records returned.
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 sow_and_subscribe -server localhost:9007 -type json \
-topic chaos -filter "/name = 'cup'"

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

The example above queries the chaos topic for stored messages that match /name = 'cup', then subscribes to matching updates. Initially, only matching messages stored in the SOW are returned. If a publisher were started that published data to the topic that matched the content filter, those messages would then be printed out to the screen in the same manner as a subscription.

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