ProducerV2 - Scoped
The ProducerV2 API provides methods to publish messages from your ServiceNow instance to a Kafka topic.
Note:
This API requires the ServiceNow
Integration Hub Action Step - Kafka Producer plugin (com.glide.hub.action_step.kafka) and is provided within the This API requires a Stream Connect subscription. For more information, see https://www.servicenow.com/products/automation-engine.html.
sn_ih_kafka namespace.ProducerV2 - send(String topicSysID, String key, String message, Boolean isSync, Object headers)
Sends the specified message to the specified Kafka topic.
| Name | Type | Description |
|---|---|---|
| topicSysID | String | Sys_id of the topic to publish the message to. Topics are stored in the Kafka Topics [sys_kafka_topic] table. |
| key | String | Name of the key for a specific partition in the topic. |
| message | String | Message text. |
| isSync | Boolean | Flag that indicates whether to require the script to wait for the send method
to complete before continuing. Valid values:
|
| headers | Object | Headers for the message, defined as key-value pairs. For example, var headers = { "origin": "sn_business_rule"
};
|
| Type | Description |
|---|---|
| None |
This example shows how to send changed incident information to the Kafka topic with a sys_id of 75135aa2ff0311105cf343d0653bf155.
var message = {
'number': current.number.toString(),
'short_description': current.short_description.toString(),
'caller_id': current.caller_id.getDisplayValue(),
'priority': current.priority.toString(),
'state': current.state.toString()
};
var headers = {
'origin': 'sn_business_rule'
};
var producer = new sn_ih_kafka.ProducerV2();
producer.send('75135aa2ff0311105cf343d0653bf155', gs.generateGUID(), JSON.stringify(message), false, headers);