0

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.

anaray
  • 309
  • 1
  • 8
  • 1
    I'm not familiar at all with the kafka apis. Do they have an API to stream data? If not, data will need to read into memory. – spencergibb Dec 03 '19 at 19:59
  • @spencergibb thanks. I am referring to following example from reactive-kafka documentation https://projectreactor.io/docs/kafka/release/reference/#api-guide-sender . KafkaSender uses a flux of SenderRecord to send data to kafka. While in Spring Cloud Gateway global filter we have Flux . So I guess only option available now would be to join all DataBuffer and convert to bytes and then create a SenderRecord. – anaray Dec 03 '19 at 21:15

0 Answers0