examples: rdkafka example using message_record type which doesn't implement ToBytes trait
Looking to add a fix or get clarification on how to use example at example-projects/rdkafka-example
let message_record =
MessageRecord::from_event(event).expect("error while serializing the event");
let delivery_status = producer
.send(
FutureRecord::to(topic_name)
.message_record(&message_record)
.key(&format!("Key {}", i)),
Duration::from_secs(10),
)
.await;
- Producer example is attempting to use MessageRecord to serialize events and send directly to Kafka.
- The FutureRecord types however requires a payload that implements ToBytes. MessageRecord doesn't have an impl for this
- It does have a payload field type Vec
but that field is only visible to the rdkafka crate .
Adding a function for example pub fn payload and pub fn headerson MessageRecord would make the payload and header fields accessible
Hi, thanks for opening this issue!
The current implementation should work as-is for binary mode. The FutureRecordExt and BaseRecordExt extension traits access the pub(crate) fields internally, so you don't need direct access to payload and headers.
You just use:
FutureRecord::to(topic_name)
.message_record(&message_record)
Could you clarify what exactly isn't working? A code snippet or failing test case would help us understand the issue.
If you're looking for structured mode support for Kafka, that's currently not implemented.