mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fix:未捕获kafka事务异常,造成canal ack异常 (#1814)
This commit is contained in:
@@ -102,10 +102,10 @@ public class CanalKafkaProducer implements CanalMQProducer {
|
|||||||
producerTmp = producer2;
|
producerTmp = producer2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kafkaProperties.getTransaction()) {
|
|
||||||
producerTmp.beginTransaction();
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
if (kafkaProperties.getTransaction()) {
|
||||||
|
producerTmp.beginTransaction();
|
||||||
|
}
|
||||||
if (!StringUtils.isEmpty(canalDestination.getDynamicTopic())) {
|
if (!StringUtils.isEmpty(canalDestination.getDynamicTopic())) {
|
||||||
// 动态topic
|
// 动态topic
|
||||||
Map<String, Message> messageMap = MQMessageUtils.messageTopics(message,
|
Map<String, Message> messageMap = MQMessageUtils.messageTopics(message,
|
||||||
@@ -130,7 +130,11 @@ public class CanalKafkaProducer implements CanalMQProducer {
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
if (kafkaProperties.getTransaction()) {
|
if (kafkaProperties.getTransaction()) {
|
||||||
producerTmp.abortTransaction();
|
try {
|
||||||
|
producerTmp.abortTransaction();
|
||||||
|
} catch (Exception e1) {
|
||||||
|
logger.error(e1.getMessage(), e1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
callback.rollback();
|
callback.rollback();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user