Skip to main content

spark sow

The sow command allows the AMPS spark CLI to query the latest messages which have been persisted to a topic. The SOW in AMPS acts as a database last update cache, and the sow command in AMPS spark CLI is one of the ways to query the database. This sow command supports regular expression topic matching and content filtering, which allow a query to be very specific when looking for data.

For the sow command to succeed, the topic queried must provide a SOW. This includes SOW topics and views, queues, and conflated topics. These features of AMPS are discussed in more detail in this guide.

Common Options - spark sow​

OptionDefinition

server

(required)

AMPS server to connect to.

topic

(required)

Topic to query.
batchsize

Batch Size to use during query.

A batch size > 1 can help improve performance, as described in Querying the State of the World.

copyPublishes records to the secondary server specified.
filterThe content 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 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 query response 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 -server localhost:9007 -type json -topic order \
-filter "/id = '1'"

{ "id" : 1, "data" : "hello, world" }
Total messages received: 1 (Infinity/s)

This sow command will query the order topic and filter results which match the xpath expression /id = '1'. This query will return the results in the topic, for example, the record published in the single-message publish example.

If the topic does not provide a SOW, the command returns an error indicating that the command is not valid for that topic.

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