1

I need to use Event Streams from a C++ program. Looking for sample code.

Tried ./rdkafka_example from librdkafka, I dont get any error message but messages dont get through. It may an be authorization issue as I could not find where to supply credentials to the code. Is there a sample c++ program anywhere?

1 Answers1

1

Librdkafka comes with a few C++ examples that can be used with Event Streams.

For example, for Event Streams on Cloud, using the rdkafka_example_cpp sample:

To produce, run:

./rdkafka_example -P -t <TOPIC> -b <BOOTSTRAP_SERVERS> \
  -X security.protocol=SASL_SSL -X sasl.mechanisms=PLAIN -X sasl.username=<USERNAME> \
  -X sasl.password=<PASSWORD> -X ssl.ca.location=<CA_PATH> -X api.version.request=true \
  -X broker.version.fallback=0.10.2.1 -X log.connection.close=false

To Consume, run:

./rdkafka_example -C -t <TOPIC> -p 0 -b <BOOTSTRAP_SERVERS> \
  -X security.protocol=SASL_SSL -X sasl.mechanisms=PLAIN -X sasl.username=<USERNAME> \
  -X sasl.password=<PASSWORD> -X ssl.ca.location=<CA_PATH> -X api.version.request=true \
  -X broker.version.fallback=0.10.2.1 -X log.connection.close=false

Replace the placeholders between <> with your Event Streams credentials.

See how the arguments passed with -X are used in the example to build a Config: https://github.com/edenhill/librdkafka/blob/master/examples/rdkafka_example.cpp#L342-L375

Mickael Maison
  • 25,067
  • 7
  • 71
  • 68