1

I am using spring boot Kafka to send messages to a topic. My requirement is to read data incrementally from a table and publish it into a topic based on a date time field and as it is a scheduled process i need to store the date-time field from each message after each successful send message to Kafka.

Any suggestions what is the best way of doing this.I believe i cannot use asynchronous callback for something like this as i need to update the variable after each call to the producer.

Also i cannot use Kafka connect due to infrastructural constraint.

1 Answers1

0
ListenableFuture<SendResult<String, String>> future = template.send(...);
SendResult<String, String> sendResult = future.get(10, TimeUnit.SECONDS);
Long timestamp = sendResult.getProducerRecord().timestamp();

If the send fails, the get will thrown an exception.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179