This commit is contained in:
mcy
2019-01-15 11:38:00 +08:00
parent 18b304f99d
commit ca41be8412

View File

@@ -144,7 +144,10 @@ public class CanalKafkaProducer implements CanalMQProducer {
// 发送扁平数据json
List<FlatMessage> flatMessages = MQMessageUtils.messageConverter(message);
if (flatMessages != null) {
int idx = 0;
int size = flatMessages.size();
for (FlatMessage flatMessage : flatMessages) {
idx++;
if (StringUtils.isEmpty(canalDestination.getPartitionHash())) {
try {
Integer partition = canalDestination.getPartition();
@@ -155,7 +158,11 @@ public class CanalKafkaProducer implements CanalMQProducer {
partition,
null,
JSON.toJSONString(flatMessage, SerializerFeature.WriteMapNullValue));
if (idx != size) {
producer2.send(record);
} else {
producer2.send(record).get();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
// producer.abortTransaction();
@@ -175,7 +182,11 @@ public class CanalKafkaProducer implements CanalMQProducer {
i,
null,
JSON.toJSONString(flatMessagePart, SerializerFeature.WriteMapNullValue));
if (idx != size) {
producer2.send(record);
} else {
producer2.send(record).get();
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
// producer.abortTransaction();