fix:未捕获kafka事务异常,造成canal ack异常 (#1814)

This commit is contained in:
nieyuan1991
2019-05-28 00:02:25 +08:00
committed by agapple
parent 4075a0623f
commit f9989e0856

View File

@@ -102,10 +102,10 @@ public class CanalKafkaProducer implements CanalMQProducer {
producerTmp = producer2;
}
if (kafkaProperties.getTransaction()) {
producerTmp.beginTransaction();
}
try {
if (kafkaProperties.getTransaction()) {
producerTmp.beginTransaction();
}
if (!StringUtils.isEmpty(canalDestination.getDynamicTopic())) {
// 动态topic
Map<String, Message> messageMap = MQMessageUtils.messageTopics(message,
@@ -130,7 +130,11 @@ public class CanalKafkaProducer implements CanalMQProducer {
} catch (Throwable e) {
logger.error(e.getMessage(), e);
if (kafkaProperties.getTransaction()) {
producerTmp.abortTransaction();
try {
producerTmp.abortTransaction();
} catch (Exception e1) {
logger.error(e1.getMessage(), e1);
}
}
callback.rollback();
}