Example usage for org.springframework.kafka.core KafkaOperations send

List of usage examples for org.springframework.kafka.core KafkaOperations send

Introduction

In this page you can find the example usage for org.springframework.kafka.core KafkaOperations send.

Prototype

ListenableFuture<SendResult<K, V>> send(Message<?> message);

Source Link

Document

Send a message with routing information in message headers.

Usage

From source file:org.springframework.kafka.listener.DeadLetterPublishingRecoverer.java

private void publish(ProducerRecord<Object, Object> outRecord, KafkaOperations<Object, Object> template) {
    try {/*from w  ww  .j  av  a 2  s.  co m*/
        template.send(outRecord).addCallback(result -> {
            if (logger.isDebugEnabled()) {
                logger.debug("Successful dead-letter publication: " + result);
            }
        }, ex -> {
            logger.error("Dead-letter publication failed for: " + outRecord, ex);
        });
    } catch (Exception e) {
        logger.error("Dead-letter publication failed for: " + outRecord, e);
    }
}