How to publish protobuf messages on confluent cloud UI

I’m trying to publish protobuf messages to a topic on the UI under the Messages tab for a topic. What sort of syntax should I be using? I’m aware it works for JSON messages but not sure how it should be done for protobuf. Attached is the UI that I’m referring to. Thank you!

Hi @minsoh,

The Messages viewer supports consuming (displaying) protobuf-formatted messages, but it doesn’t yet support producing protobuf. There is an open request for this internal to Confluent and I’ve added a link to this thread.

In the meantime, to produce a test protobuf-formatted message, you could use the Confluent CLI like this:

confluent kafka topic produce <TOPIC> \
  --value-format protobuf \
  --schema-id <SCHEMA ID> \
  --schema-registry-endpoint <SR ENDPOINT> \
  --schema-registry-api-key <SR API KEY> \
  --schema-registry-api-secret <SR API SECRET> 

Or, with the kafka-console-protobuf-producer CLI tool it would look like:

  kafka-protobuf-console-producer \
    --bootstrap-server <BOOTSTRAP SERVER> \
    --topic <TOPIC>  \
    --producer.config config.properties \
    --property value.schema.id=<SCHEMA ID> \
    --property schema.registry.url=<SR ENDPOINT> \
    --property basic.auth.credentials.source=USER_INFO \
    --property basic.auth.user.info=<SR API KEY>:<SR API SECRET>

For either CLI, you would provide a JSON payload. E.g., for this schema:

syntax = "proto3";
package io.confluent.developer;

message MyRecord {
  int32 int = 1;
  string str = 2;
}

An example message produced via either CLI is {"int":123,"str":"foobar"}.

HTH,
Dave

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.