Function rust_with_kafka_tls::publish_messages::publish_messages
source · [−]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 fileKAFKA_TLS_CLIENT_KEY
- path to the server key fileKAFKA_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
producer
- initializedrdkafka::producer::FutureProducer
that will publish messages to the kafkatopic_name
topic_name
- publish messages this kafka topic
Examples
cargo build --example run-producer
export RUST_BACKTRACE=1
export RUST_LOG=info
./target/debug/examples/run-producer -b $KAFKA_BROKERS -t testing