SEND MESSAGE
Overview
Sends one or more messages as a text payload to a messaging endpoint. Each messaging platform offers different connection and processing options.
BATCH
The BATCH option is only needed when you want to send one or more messages using the data pipeline dataset. When doing so, if 0 records are in the pipeline data, 0 messages will be sent. However, if you would like to send a single message regardless of the number of records in the pipeline, simply omit the BATCH option.
OPTIONS Parameter
Syntax
Sends a single payload to a messaging platform of for incoming records one at a time or in a batch.
SEND MESSAGE [CONNECTION]
PAYLOAD (...)
OPTIONS (...)
{ WITH
{ TIMEOUT N }
{ BATCH N }
}
;PAYLOAD |
The payload to use or build for upsert or delete operations; may contain DataZen functions and pipeline variables |
OPTIONS |
The messaging platform-specific set of options for upsert or delete operations as a comma-separated list of key=value settings (ex: applicationId=test) |
TIMEOUT |
A timeout value in seconds |
BATCH |
The number of records to process in a single call |
Example 1
-- Sends a single message to a Kafka topic PUSH INTO MESSAGE [kafka-cloud] PAYLOAD (This is a test message sent to the topic) OPTIONS (applicationId=integration,topicName=test) ;
Example 2
-- Retrieve a list of database tables from a SQL Server database
SELECT * FROM DB [sql] (SELECT name FROM sys.tables);
-- build a json object for each row
ADD COLUMN (json = '{ "name": "{{name}}" }');
-- build as many batches of json documents as needed into an array
-- of up to 50 objects
ZIP COLUMN 'json' FORMAT JSON BATCH 50;
-- Batching into a messaging endpoint sends N records at once,
-- as individual messages. As a result, we are pre-batching ahead
-- to build array of objects first.
-- Sends a message containing the batched JSON objects to a Kafka endpoint
SEND MESSAGE [kafka-cloud]
PAYLOAD ({{json}})
OPTIONS (applicationId=integration,topicName=rssfeed)
WITH
BATCH 1
;
