mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
fixed #1420
This commit is contained in:
@@ -144,7 +144,10 @@ public class CanalKafkaProducer implements CanalMQProducer {
|
|||||||
// 发送扁平数据json
|
// 发送扁平数据json
|
||||||
List<FlatMessage> flatMessages = MQMessageUtils.messageConverter(message);
|
List<FlatMessage> flatMessages = MQMessageUtils.messageConverter(message);
|
||||||
if (flatMessages != null) {
|
if (flatMessages != null) {
|
||||||
|
int idx = 0;
|
||||||
|
int size = flatMessages.size();
|
||||||
for (FlatMessage flatMessage : flatMessages) {
|
for (FlatMessage flatMessage : flatMessages) {
|
||||||
|
idx++;
|
||||||
if (StringUtils.isEmpty(canalDestination.getPartitionHash())) {
|
if (StringUtils.isEmpty(canalDestination.getPartitionHash())) {
|
||||||
try {
|
try {
|
||||||
Integer partition = canalDestination.getPartition();
|
Integer partition = canalDestination.getPartition();
|
||||||
@@ -155,7 +158,11 @@ public class CanalKafkaProducer implements CanalMQProducer {
|
|||||||
partition,
|
partition,
|
||||||
null,
|
null,
|
||||||
JSON.toJSONString(flatMessage, SerializerFeature.WriteMapNullValue));
|
JSON.toJSONString(flatMessage, SerializerFeature.WriteMapNullValue));
|
||||||
producer2.send(record);
|
if (idx != size) {
|
||||||
|
producer2.send(record);
|
||||||
|
} else {
|
||||||
|
producer2.send(record).get();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
// producer.abortTransaction();
|
// producer.abortTransaction();
|
||||||
@@ -175,7 +182,11 @@ public class CanalKafkaProducer implements CanalMQProducer {
|
|||||||
i,
|
i,
|
||||||
null,
|
null,
|
||||||
JSON.toJSONString(flatMessagePart, SerializerFeature.WriteMapNullValue));
|
JSON.toJSONString(flatMessagePart, SerializerFeature.WriteMapNullValue));
|
||||||
producer2.send(record);
|
if (idx != size) {
|
||||||
|
producer2.send(record);
|
||||||
|
} else {
|
||||||
|
producer2.send(record).get();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
// producer.abortTransaction();
|
// producer.abortTransaction();
|
||||||
|
|||||||
Reference in New Issue
Block a user