Skip to main content
InterSystems Supply Chain Orchestrator 2024.1
AskMe (beta)
Loading icon

Sending Messages to Kafka from a Production

An InterSystems IRIS interoperability production can be a Kafka Producer, which sends messages to a Kafka topic. You have two options: use a built-in business operation or create a custom business operation that uses the Kafka outbound adapter. There is also an API for use outside of a production.

Using the Business Operation

InterSystems provides a built-in business operation that can be used to send messages to a Kafka topic without needing to write custom code. To use this business operation:

  1. Add EnsLib.Kafka.BusinessOperation to your production. See Adding Business Hosts.

  2. Configure settings of this business host as described in Kafka Settings.

  3. Configure other business hosts to send EnsLib.Kafka.MessageOpens in a new tab requests to this business operation. See Kafka Message Class for details.

When this business operation receives a message of type EnsLib.Kafka.MessageOpens in a new tab, it sends the contents of that message to the Kafka topic specified in the message.

Kafka Message Class

The EnsLib.Kafka.MessageOpens in a new tab message class has the following properties:

  • topic defines the Kafka topic where the Producer is sending messages.

  • value (a string) defines the content of the Kafka message. If value is set, you should not set binaryValue.

  • binaryValue (a binary stream of arbitrary length) defines the content of the Kafka message when the length of the message exceeds the maximum length of a %String. If binaryValue is set, you should not set value.

  • key defines an optional tag for the Kafka message.

Using the Adapter

If the built-in Kafka business operation does not meet your needs, you can directly use the Kafka outbound adapter as follows:

  1. Create a custom business operation class:

    • The class should extend Ens.BusinessOperationOpens in a new tab.

    • The ADAPTER parameter should equal EnsLib.Kafka.OutboundAdapterOpens in a new tab.

    • The class should define a message map:

      XData MessageMap
      {
      <MapItems>
        <MapItem MessageType="messageclass">
          <Method>methodname</Method>
        </MapItem>
        ...
      </MapItems>
      }
      
    • The class should define all the methods in the message map. These methods are known as message handlers. Each message handler should have the following signature:

      Method Sample(pReq As RequestClass, Output pResp As ResponseClass) As %Status {
      }

      The message handlers can call the instance methods of the adapter, which is accessible as the Adapter property of the business operation. The general syntax for calling these methods is as follows:

       do ..Adapter.MethodName(arguments)

      The Kafka outbound adapter has one instance method, named SendMessage(), with the following signature:

      Method SendMessage(message As EnsLib.Kafka.Message) As %Status{
      }
  2. Add your business operation to your production. See Adding Business Hosts.

  3. Configure settings of this business host as described in Kafka Settings.

  4. Configure other business hosts to send requests to this business operation.

See Also

FeedbackOpens in a new tab