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
| Option | Definition |
|---|---|
| AMPS server to connect to. |
| 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.) |
backlog | Request a max_backlog of greater than 1 when receiving from a queue. (See the chapter on Message Queues in this guide for more information.) |
copy | Publishes records to the secondary server specified. |
delta | Use delta subscription (sends a delta_subscribe command to AMPS). |
filter | Content filter to use. |
format | Optional format used for displaying messages. May contain literal separator characters mixed with format tags. Allowed tags are:
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: |
proto | Protocol to use. In this release, AMPS spark CLI supports Defaults to |
| Specifies whether to use an SSL-secured connection ( Values: Default: |
type | For 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: |
| Allows a custom URI scheme to be specified. When both |
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.