DataZen Documentation
DataZen User Guide

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

The OPTIONS clause configures messaging-platform settings as a comma-separated list of key-value pairs. Supported keys vary by messaging engine.

  • Option names are case-insensitive.
  • Values are trimmed; surrounding " or ' characters are stripped automatically.
  • DataZen functions and variables are supported in option values.

Example for Kafka:

OPTIONS 'ApplicationId=testapp,CorrelationId=@jobguid'
Kafka
Option Description
TopicName Target Kafka topic name.
KeyFieldSeparator Separator used when multiple upsert key columns are combined into the Kafka message key. The key column list itself comes from the pipeline key settings, not from OPTIONS.
ApplicationId Application identifier associated with the message.
CorrelationId Correlation identifier for relating related messages.
ReplyTo Reply-to destination for response routing.
Azure Service Bus
Option Description
QueueOrTopicName Target queue or topic name.
AzBusQueueKind Queue or topic kind. Supported values: Dynamic (default), Queue, or Topic (also accepts 0, 1, or 2).
ForwardProperties When true, 1, yes, or y, forwards additional message properties.
MessageId Message identifier.
Subject Message subject / label.
To Destination address for the message.
ReplyTo Reply-to address.
CorrelationId Correlation identifier for relating related messages.
Azure Event Hub
Option Description
EventHubName Target Event Hub name.
MessageId Message identifier.
CorrelationId Correlation identifier for relating related messages.
AWS SQS
Option Description
QueueName Target SQS queue name.
MessageGroupId FIFO queues only. Message group ID. Can be a static value or a {{field}} reference. When blank, no group ID is sent.
DeduplicationIdField FIFO queues only. Field used to build a deduplication ID. When blank, no deduplication ID is sent and the queue is assumed to use content-based deduplication.
RabbitMQ
Option Description
RoutingKey Routing key used when publishing the message.
ReplyTo Reply-to queue or address.
Priority Message priority (integer).
MessageId Message identifier.
AppId Application identifier associated with the message.
Expiration Message expiration in milliseconds (long integer).
Persist When true, 1, yes, or y, marks the message as persistent.
Google Pub/Sub
Option Description
TopicName Target Pub/Sub topic name.
MSMQ
Option Description
QueueName Target MSMQ queue name.
Label Message label.
Formatter Message formatter used when writing to the queue.
CorrelationId Correlation identifier for relating related messages.
IsAuthenticated When true, 1, yes, or y, marks the message as authenticated.

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
;