I upgraded spring from 2.x to 3.x and spring-kafka version is also changed. Due to this change ‘ListenableFuture’ is deprecated and I need to use ‘CompletableFuture’. How to change below method?
public void publish( Event event ) {
ListenableFuture<SendResult<String, Event>> send = kafkaTemplate.send( kafkaTopicName, event );
send.addCallback( new ListenableFutureCallback<SendResult<String, Event>>() {
@Override
public void onSuccess( SendResult<String, Event> result ) {
if ( result != null ) {
log.info( "published event='{}' with offset={}", result, result.getRecordMetadata().offset() );
}
}
@Override
public void onFailure( Throwable ex ) {
log.error( "unable to publish event={}", event, ex );
}
} );
}