Sending Messages to Kafka from a Production
InterSystems IRIS becomes a Kafka Producer when an interoperability production includes a business operation that uses the Kafka outbound adapter. This adapter allows the business operation to send messages to a Kafka topic. You have two options when using a production as a Kafka Producer: use a built-in business operation that leverages the outbound adapter or build your own business operation that uses the adapter.
The Kafka outbound adapter is the class EnsLib.Kafka.OutboundAdapterOpens in a new tab. It includes the following settings, all of which appear in the Management Portal as settings for the business operation that uses the adapter:
Servers defines a comma-separated list of IP address:port entries that identify servers in the Kafka cluster.
ClientID defines the Kafka client ID of the Producer.
Credentials defines the InterSystems credentials that correspond to the username and password of a Kafka client. For details on creating credentials, see Defining Reusable Items for Use in Settings.
For general information about building a custom business operation that uses an outbound adapter, see Defining Business Operations.
Send Kafka Messages
The class of the messages sent by the outbound adapter to Kafka is EnsLib.Kafka.MessageOpens in a new tab, which contains 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.
The outbound adapter's SendMessage() method takes a EnsLib.Kafka.MessageOpens in a new tab object as its sole argument, and sends that message to the Kafka server. For example, a custom business operation could call the adapter’s method by including the following:
Built-in Business Operation
Rather than building a custom business operation that uses the outbound adapter, you can simply add EnsLib.Kafka.OperationOpens in a new tab to the production and define the adapter properties using the Management Portal settings. This business operation calls the adapter's SendMessage() method when it receives a request from another business host in the production. This request should contain a Kafka message of type EnsLib.Kafka.MessageOpens in a new tab.
For basic information about adding a business operation to a production, see Adding Business Hosts.