---
sourceDocument: Australia API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/de-DE/api-reference

 Release :

    - australia

ft:locale :

    - de-DE

ft:publication_title :

    - Australia API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# MIDHermesProducer - Global

# MIDHermesProducer - Global {#ariaid-title1}

* Freigeben Version: Australia
* 
* Aktualisiert 12. März 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 Minuten Lesedauer

The MIDHermesProducer API provides a method to send data from the MID Server to a Hermes topic.

Sending data via the [Hermes Messaging Service](https://www.servicenow.com/docs/access?context=hermes-messaging-service&version=australia&pubname=australia-servicenow-platform&ft:locale=en-US) rather than using the [MID Server ECC Queue](https://www.servicenow.com/docs/access?context=ecc-queue-mid-server&version=australia&pubname=australia-servicenow-platform&ft:locale=en-US) can be a more efficient way to get data to a ServiceNow instance.

This API requires the ServiceNow MID Hermes API (com.glide.mid.hermes_api) plugin. The calling user must have the kafka_admin role. Before calling this API, follow the steps to [Configure the MID Hermes API Extension](https://www.servicenow.com/docs/access?context=MID-hermes-API&version=australia&pubname=australia-integrate-applications&section=configure-mid-hermes-api&ft:locale=en-US).

Use this API in scripts that run on the MID Server, such as MID Server background scripts or in [Workflow Studio](https://www.servicenow.com/docs/access?context=workflow-studio&version=australia&pubname=australia-build-workflows&ft:locale=en-US) action script steps with the Required Runtime set to MID.

## MIDHermesProducer - MIDHermesProducer() {#ariaid-title2}

Creates a MIDHermesProducer for sending messages to Hermes topics.
{#MIDHermesProd-MIDHermesProd__table_j1w_c1c_23c__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 1. Parameters]

{#MIDHermesProd-MIDHermesProd__table_j1w_c1c_23c}  
This example instantiates a MIDHermesProducer.

    var producer = new MIDHermesProducer();

## MIDHermesProducer - send(Object options) {#ariaid-title3}

Sends a message from the MID Server to the specified Hermes topic.
The 4000-4050 port range must be open to send messages to a Hermes topic. For more information, see [Producing and consuming messages from a Kafka client](https://www.servicenow.com/docs/access?context=producing-consuming-hermes&version=australia&pubname=australia-servicenow-platform&ft:locale=en-US).
{#MIDHermesProd-send_O__table_n1j_g1c_23c__entry__3}

| Name | Type | Description |
|-|-|-|
| options | Object | Contains configuration parameters for the message. { applicationId: "String", callbackFunction: function(), headers: {Object}, key: "String", message: "String", topic: "String" } |
| options.applicationId | String | Optional. Application identifier for topic routing. When provided, messages are routed to `snc.{instance}.{applicationId}.{topic}`, otherwise they are routed to `snc.{instance}.{topic}`. |
| options.onErrorCallback | Function | Optional. JavaScript function to execute if message delivery fails. The function accepts two parameters: String `errorMessage` and String `errorType` (the fully qualified Java exception class name). function(errorMessage, errorType) { //implement error handling here }; |
| options.headers | Object | Optional. Key-value pairs for message headers. Any headers supported by Apache Kafka are valid. |
| options.key | String | Optional. Message key for partitioning in Apache Kafka. Messages with the same key are sent to the same partition, ensuring ordering. |
| options.message | String | Content of the message to send to the topic. Any value formatted as a string is valid. |
| options.topic | String | Name of the Hermes topic to send the message to. Hinweis: Don't include the instance prefix; it is added automatically. |
[Tabelle : 2. Parameters]

{#MIDHermesProd-send_O__table_n1j_g1c_23c} {#MIDHermesProd-send_O__table_o1j_g1c_23c__entry__2}

| Type | Description |
|-|-|
| None | This method does not return a value. Message delivery is asynchronous. Success: Messages are delivered asynchronously to Hermes Kafka brokers. Check MID Server logs for delivery confirmation. Failure: If message delivery fails, the optional callback function (if provided) is invoked with error details. Common errors include: * `org.apache.kafka.common.errors.TimeoutException`: Kafka broker unreachable or network issues. Check firewall rules for Hermes bootstrap address and ports. * `com.service_now.mid.hermes_api.exception.MIDHermesAPIExtensionNotStartedException`: Extension not started. Verify MID Hermes API extension context is active. * `java.lang.IllegalArgumentException`: Invalid parameters. Ensure topic and message are provided. {#MIDHermesProd-send_O__ul_tdc_1x5_33c} Additional steps to resolve errors: * Verify MID Hermes API extension is running in MID Server UI. * Check network connectivity to Hermes. * Review MID Server logs with property mid.hermes.debug=true for detailed diagnostics. * Confirm IPKI certificate is valid in MID Server keystore. {#MIDHermesProd-send_O__ul_xx4_ky5_33c} |
[Tabelle : 3. Returns]

{#MIDHermesProd-send_O__table_o1j_g1c_23c}  
This example sends a message to a Hermes topic.

    // Create producer instance 
    var producer = new MIDHermesProducer(); 

    // Define error callback function 
    var errorCallback = function(errorMessage, errorType) {
        gs.error("Message delivery failed: " + errorType + " - " + errorMessage);
    }; 

    // Send message with all optional parameters 
    producer.send({ 
        topic: "order-events", 
        applicationId: "sn_streamconnect", 
        message: JSON.stringify({ 
            orderId: "ORD-12345", 
            status: "completed", 
            timestamp: new Date().getTime() 
        }), 
        key: "customer-456", 
        headers: { 
            "content-type": "application/json", 
            "source": "mid-server", 
            "version": "1.0" 
        }, 
        onErrorCallback: errorCallback 
    });

The message is sent asynchronously. Check MID Server logs for delivery confirmation.

