Open Source API Gateway
2. Enterprise Integration Patterns

kafkaProducer

Version

Publishes the body of the request as a message to an Apache Kafka topic.

The interceptor needs the Membrane Kafka Extension. Without the extension Membrane does not start. Contact predic8 for the extension.

Example Configuration

kafkaProducer:
bootstrapServers: kafka.example.com:9092
topic: orders
key: headers['X-Order-Id']
kafkaProducer:
   bootstrapServers: kafka.example.com:9092
   topic: orders
   key: headers['X-Order-Id']

Syntax

kafkaProducer:
bootstrapServers: <string> # required
topic: <string> # required
'$ref': <string>
acks: <string>
batchSize: <int>
clientId: <string>
compressionType: <string>
deliveryTimeoutMs: <int>
enableIdempotence: <boolean>
key: <string>
language: groovy
lingerMs: <int>
maxRequestSize: <int>
requestTimeoutMs: <int>
saslJaasConfig: <string>
saslMechanism: <string>
securityProtocol: <string>
xmlConfig: {}
kafkaProducer:
  bootstrapServers: <string> # required
  topic: <string> # required
  '$ref': <string>
  acks: <string>
  batchSize: <int>
  clientId: <string>
  compressionType: <string>
  deliveryTimeoutMs: <int>
  enableIdempotence: <boolean>
  key: <string>
  language: groovy
  lingerMs: <int>
  maxRequestSize: <int>
  requestTimeoutMs: <int>
  saslJaasConfig: <string>
  saslMechanism: <string>
  securityProtocol: <string>
  xmlConfig: {}

Attributes

NameRequiredDefaultDescriptionExamples
$reffalse-Reference a component defined under components.-
acksfalseallNumber of brokers that must acknowledge a message before it counts as sent.0 | 1 | all
batchSizefalse16384Maximum size of a batch of messages in bytes.-
bootstrapServerstrue-Comma separated list of Kafka brokers used for the initial connection.kafka1.example.com:9092,kafka2.example.com:9092
clientIdfalse-Client id sent to the brokers, useful for logging and quotas on the Kafka side.membrane
compressionTypefalsenoneCompression of the message batches.none | gzip | snappy | lz4 | zstd
deliveryTimeoutMsfalse120000Upper bound in milliseconds for reporting success or failure of a send, including retries.-
enableIdempotencefalsetruePrevents duplicate messages when the producer retries. Requires acks=all.-
keyfalse-Expression computing the record key. The key determines the partition. Without a key Kafka distributes the messages over the partitions.headers['X-Order-Id']
languagefalseSpELScripting language used to evaluate the value expression.SpEL | groovy | jsonpath | xpath
lingerMsfalse0Time in milliseconds to wait for more messages before a batch is sent.-
maxRequestSizefalse1048576Maximum size of a single message in bytes.-
requestTimeoutMsfalse30000Time in milliseconds to wait for the answer of a broker.-
saslJaasConfigfalse-JAAS login configuration for SASL authentication.org.apache.kafka.common.security.plain.PlainLoginModule required username="user" password="secret";
saslMechanismfalse-SASL mechanism for authentication, used with the security protocols SASL_PLAINTEXT and SASL_SSL.PLAIN | SCRAM-SHA-256 | SCRAM-SHA-512
securityProtocolfalse-Protocol used to talk to the brokers. Kafka default is PLAINTEXT.PLAINTEXT | SSL | SASL_PLAINTEXT | SASL_SSL
topictrue-Topic the messages are sent to.orders

Child Structure

ElementCardinalityDescription
xmlConfig0..1XML namespace declarations for XPath expressions in the value.

Can be used in