fix序列化的一些问题, kafka生产端统一使用异步

This commit is contained in:
mcy
2018-09-17 11:10:50 +08:00
parent db56effd91
commit 7005c11ac2
3 changed files with 11 additions and 11 deletions

View File

@@ -180,8 +180,8 @@ public class SimpleCanalConnector implements CanalConnector {
Ack ackBody = Ack.parseFrom(ack.getBody());
if (ackBody.getErrorCode() > 0) {
throw new CanalClientException("something goes wrong when doing authentication: "
+ ackBody.getErrorMessage());
throw new CanalClientException(
"something goes wrong when doing authentication: " + ackBody.getErrorMessage());
}
connected = true;
@@ -323,7 +323,9 @@ public class SimpleCanalConnector implements CanalConnector {
Packet p = Packet.parseFrom(data);
switch (p.getType()) {
case MESSAGES: {
if (!p.getCompression().equals(Compression.NONE)) {
// if (!p.getCompression().equals(Compression.NONE)) {
if (!p.getCompression().equals(Compression.NONE)
&& !p.getCompression().equals(Compression.COMPRESSIONCOMPATIBLEPROTO2)) {
throw new CanalClientException("compression is not supported in this connector");
}
@@ -360,11 +362,8 @@ public class SimpleCanalConnector implements CanalConnector {
.setBatchId(batchId)
.build();
try {
writeWithHeader(Packet.newBuilder()
.setType(PacketType.CLIENTACK)
.setBody(ca.toByteString())
.build()
.toByteArray());
writeWithHeader(
Packet.newBuilder().setType(PacketType.CLIENTACK).setBody(ca.toByteString()).build().toByteArray());
} catch (IOException e) {
throw new CanalClientException(e);
}

View File

@@ -36,7 +36,8 @@ public class MessageDeserializer implements Deserializer<Message> {
CanalPacket.Packet p = CanalPacket.Packet.parseFrom(data);
switch (p.getType()) {
case MESSAGES: {
if (!p.getCompression().equals(CanalPacket.Compression.NONE)) {
if (!p.getCompression().equals(CanalPacket.Compression.NONE)
&& !p.getCompression().equals(CanalPacket.Compression.COMPRESSIONCOMPATIBLEPROTO2)) {
throw new CanalClientException("compression is not supported in this connector");
}