标签:factory actor ack failure mes rod inf list message
1,配置kafakaproducer和consummer。
2,发送消息通过回调的方式处理发送成功或者失败。
public class Sender { Logger log = LoggerFactory.getLogger(Sender.class); @Autowired private KafkaTemplate kafkaTemplate; public void sendMessage(String topic, Event event) { ListenableFuture<SendResult<Integer, String>> future = kafkaTemplate.send(topic, message); future.addCallback(new ListenableFutureCallback<SendResult<Integer, String>>() { @Override public void onSuccess(SendResult<Integer, String> result) { log.info("send success {}", result.getProducerRecord().value()); } @Override public void onFailure(Throwable ex) { log.warn("send fail {}", ex.getMessage()); } }); } }
标签:factory actor ack failure mes rod inf list message
原文地址:http://www.cnblogs.com/yimixiong/p/7599381.html