ProduceMessage
Sends a raw message to Kafka.
Minimum Required Inputs
When producing a message, only the Topic input is required:
EXEC ProduceMessage Topic = 'mytopic'
The other properties have the following default behaviors:
- Partition: The native library determines the partition automatically, taking into account any relevant options from ProducerProperties.
- KeyText and KeyBytes: If neither of these is provided, the provider produces a message without a key.
- MessageText and MessageBytes: If neither of these is provided, the provider produces a message without any content.
Omitting the key or message content may make the message unreadable with certain provider settings. For example, setting MessageKeyType to integer may cause read failures with messages that have no keys. TypeDetectionScheme MessageOnly and MessageKeyType Binary are recommended if you need to read messages containing arbitrary content or keys.
KeyText/KeyBytes and MessageText/MessageBytes
The key and message can each be provided either as text or base64-encoded strings. KeyBytes and MessageBytes accept base64-encoded strings. The provider decodes these values into bytes before sending the message to Kafka.
KeyText and MessageText accept any text. The provider encodes these values as UTF-8 before sending the message to Kafka.
For example, the following statement inserts a message with no key and content that is a single NUL byte:
EXEC ProduceMessage Topic = 'mytopic', MessageBytes = 'AA=='
Input
Name | Type | Required | Description |
Topic | String | True | The topic that contains the message. |
Partition | String | False | The partition the message is assigned to. Must be valid for the given topic. Automatically assigned by the native client if not set. |
KeyText | String | False | The message given as text. The value is encoded as UTF-8 before being sent to Kafka. Do not set if KeyBytes is given. |
KeyBytes | String | False | The message key given as a base64 encoded string. Do not set if KeyText is given. |
MessageText | String | False | The message key given as text. The value is encoded as UTF-8 before being sent to Kafka. Do not set if MessageBytes is given. |
MessageBytes | String | False | The message value given as a base64 encoded string. Do not set if MessageText is given. |
Result Set Columns
Name | Type | Description |
PartitionWritten | Int | The partition that the message was written to. Is the same as Partition if that parameter is given. |
OffsetWritten | Long | The position in the partition that the message was written to. |
TimestampWritten | Long | The Unix timestamp of the instant the message was committed to the partition. |
KeyWritten | String | The base64 data of the key that was written. Is NULL if neither Key nor KeyBytes was provided. |
MessageWritten | String | The base64 data of the value that was written. Is NULL if neither Message nor MessageBytes was provided. |
Success | Bool | Whether the operation was successful. |