Java Code Examples for com.alibaba.otter.canal.protocol.Message#setRawEntries()
The following examples show how to use
com.alibaba.otter.canal.protocol.Message#setRawEntries() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CanalMessageDeserializer.java From canal-1.1.3 with Apache License 2.0 | 5 votes |
public static Message deserializer(byte[] data, boolean lazyParseEntry) { try { if (data == null) { return null; } else { CanalPacket.Packet p = CanalPacket.Packet.parseFrom(data); switch (p.getType()) { case MESSAGES: { if (!p.getCompression().equals(Compression.NONE) && !p.getCompression().equals(Compression.COMPRESSIONCOMPATIBLEPROTO2)) { throw new CanalClientException("compression is not supported in this connector"); } CanalPacket.Messages messages = CanalPacket.Messages.parseFrom(p.getBody()); Message result = new Message(messages.getBatchId()); if (lazyParseEntry) { // byteString result.setRawEntries(messages.getMessagesList()); result.setRaw(true); } else { for (ByteString byteString : messages.getMessagesList()) { result.addEntry(CanalEntry.Entry.parseFrom(byteString)); } result.setRaw(false); } return result; } case ACK: { Ack ack = Ack.parseFrom(p.getBody()); throw new CanalClientException("something goes wrong with reason: " + ack.getErrorMessage()); } default: { throw new CanalClientException("unexpected packet type: " + p.getType()); } } } } catch (Exception e) { throw new CanalClientException("deserializer failed", e); } }
Example 2
Source File: CanalMessageSerializerUtil.java From canal with Apache License 2.0 | 5 votes |
public static Message deserializer(byte[] data, boolean lazyParseEntry) { try { if (data == null) { return null; } else { CanalPacket.Packet p = CanalPacket.Packet.parseFrom(data); switch (p.getType()) { case MESSAGES: { if (!p.getCompression().equals(CanalPacket.Compression.NONE) && !p.getCompression().equals(CanalPacket.Compression.COMPRESSIONCOMPATIBLEPROTO2)) { throw new CanalClientException("compression is not supported in this connector"); } CanalPacket.Messages messages = CanalPacket.Messages.parseFrom(p.getBody()); Message result = new Message(messages.getBatchId()); if (lazyParseEntry) { // byteString result.setRawEntries(messages.getMessagesList()); result.setRaw(true); } else { for (ByteString byteString : messages.getMessagesList()) { result.addEntry(CanalEntry.Entry.parseFrom(byteString)); } result.setRaw(false); } return result; } case ACK: { CanalPacket.Ack ack = CanalPacket.Ack.parseFrom(p.getBody()); throw new CanalClientException("something goes wrong with reason: " + ack.getErrorMessage()); } default: { throw new CanalClientException("unexpected packet type: " + p.getType()); } } } } catch (Exception e) { throw new CanalClientException("deserializer failed", e); } }
Example 3
Source File: CanalMessageDeserializer.java From canal with Apache License 2.0 | 5 votes |
public static Message deserializer(byte[] data, boolean lazyParseEntry) { try { if (data == null) { return null; } else { CanalPacket.Packet p = CanalPacket.Packet.parseFrom(data); switch (p.getType()) { case MESSAGES: { if (!p.getCompression().equals(Compression.NONE) && !p.getCompression().equals(Compression.COMPRESSIONCOMPATIBLEPROTO2)) { throw new CanalClientException("compression is not supported in this connector"); } CanalPacket.Messages messages = CanalPacket.Messages.parseFrom(p.getBody()); Message result = new Message(messages.getBatchId()); if (lazyParseEntry) { // byteString result.setRawEntries(messages.getMessagesList()); result.setRaw(true); } else { for (ByteString byteString : messages.getMessagesList()) { result.addEntry(CanalEntry.Entry.parseFrom(byteString)); } result.setRaw(false); } return result; } case ACK: { Ack ack = Ack.parseFrom(p.getBody()); throw new CanalClientException("something goes wrong with reason: " + ack.getErrorMessage()); } default: { throw new CanalClientException("unexpected packet type: " + p.getType()); } } } } catch (Exception e) { throw new CanalClientException("deserializer failed", e); } }