Creating Reactive Kafka SenderRecord from Flux<DataBuffer>

353 Views Asked by At

I am doing a prototype integrating Spring Cloud Gateway with Reactive Kafka. My goal is to push the post body to kafka. I have access to Flux which could potentially give me the body in chunks. Need expert advice how to convert this Flux of DataBuffer to a SenderRecord and push this to kafka nonblocking.

I tried with DataBufferUtils.join to merge the DataBuffer to get the bytes[] and uses this create a SenderRecord. Is there a better way to this (can we avoid allocating the bytes array)?

Implementation detail: I have Spring Cloud Gateway Global Filter for kafka (url structure: kafka://<producer-template>?topic=<topicname>. Then read the body ie flux and create kafkaSender.

Thank you.

0

There are 0 best solutions below