Cookbook: Publish
This section presents common recipes for publishing to a topic in AMPS using the Command
or Message
interfaces. This section provides information on how to configure the request to AMPS. You can adapt this information to your application and the specific interface you are using.
Command: publish
The AMPS server does not return a stream of messages in response to a publish
command.
AMPS publish
commands do not return a stream of messages. A publish command must be used with asynchronous message processing and should typically pass an empty message handler.
Basic Publish
In its simplest form, a publish needs only the topic to publish to and the data to publish. The AMPS client automatically constructs the necessary AMPS headers and formats the full publish
command.
In many cases, a publisher only needs to use the basic publish
command.
Topic
(required)
Sets the topic to publish to. The topic specified must be a literal topic name. Regular expression characters in the topic name are not interpreted. Some topics in AMPS, such as views and conflated topics, cannot be published to directly. Instead, a publisher must publish to the underlying topics.
Data
The data to publish to the topic. The AMPS client does not interpret, escape, or validate this data: the data is provided to the server verbatim.
Publish with CorrelationId
AMPS provides publishers with a header field that can be used to contain arbitrary data, the CorrelationId
.
Topic
(required)
Sets the topic to publish to. The topic specified must be a literal topic name. Regular expression characters in the topic name are not interpreted. Some topics in AMPS, such as views and conflated topics, cannot be published to directly. Instead, a publisher must publish to the underlying topics.
Data
The data to publish to the topic. The AMPS client does not interpret, escape, or validate this data: the data is provided to the server verbatim.
CorrelationId
The CorrelationId
to provide on the message. AMPS provides the CorrelationId
to subscribers. The CorrelationId
has no significance for AMPS. The CorrelationId
may only contain characters that are valid in base-64 encoding.
Publish with Explicit SOW Key
When publishing to a SOW topic that is configured to require an explicit SOW key, the publisher needs to set the SowKey
header on the message.
Topic
(required)
Sets the topic to publish to. The topic specified must be a literal topic name. Regular expression characters in the topic name are not interpreted. Some topics in AMPS, such as views and conflated topics, cannot be published to directly. Instead, a publisher must publish to the underlying topics.
Data
The data to publish to the topic. The AMPS client does not interpret, escape, or validate this data: the data is provided to the server verbatim.
SowKey
The SOW Key to use for this message. This header is only supported for publishes to a topic that requires an explicit SOW Key.
Last updated