pub async fn publish_messages(producer: &FutureProducer, topic_name: &str)
Expand description

publish_messages

Publish messages to a kafka topic_name with an initialized rdkafka::producer::FutureProducer using client tls assets based off environment variables.

Optional - Set TLS Asset Paths

You can either use the included tls assets within the github repo rust-with-strimzi-kafka-and-tls/kubernetes/tls directory or export the environment variables:

  • KAFKA_TLS_CLIENT_CA - path to the Certificate Authority file
  • KAFKA_TLS_CLIENT_KEY - path to the server key file
  • KAFKA_TLS_CLIENT_CERT - path to the server certificate file

Set Broker Addresses

Export this environment variable to the correct broker fqdns and ports:

  • KAFKA_BROKERS - comma delimited list of kafka brokers (format: fqdn1:port,fqdn2:port,fqdn3:port)

Arguments

Examples

cargo build --example run-producer
export RUST_BACKTRACE=1
export RUST_LOG=info
./target/debug/examples/run-producer -b $KAFKA_BROKERS -t testing