public void unsubscribe() throws CanalClientException { waitClientRunning(); try { writeWithHeader( channel, Packet.newBuilder() .setType(PacketType.UNSUBSCRIPTION) .setBody( Unsub.newBuilder() .setDestination(clientIdentity.getDestination()) .setClientId(String.valueOf(clientIdentity.getClientId())) .build() .toByteString()) .build() .toByteArray()); // Packet p = Packet.parseFrom(readNextPacket(channel)); Ack ack = Ack.parseFrom(p.getBody()); if (ack.getErrorCode() > 0) { throw new CanalClientException( "failed to unSubscribe with reason: " + ack.getErrorMessage()); } } catch (IOException e) { throw new CanalClientException(e); } }