@Override
  public void appendMessages(Tpp tpp, Collection<MessageBatchWithRawData> batches)
      throws Exception {
    ByteBuf bodyBuf = Unpooled.buffer();
    KafkaMessageBrokerSender sender = getSender(tpp.getTopic());
    try {
      for (MessageBatchWithRawData batch : batches) {
        List<PartialDecodedMessage> pdmsgs = batch.getMessages();
        for (PartialDecodedMessage pdmsg : pdmsgs) {
          m_messageCodec.encodePartial(pdmsg, bodyBuf);
          byte[] bytes = new byte[bodyBuf.readableBytes()];
          bodyBuf.readBytes(bytes);
          bodyBuf.clear();

          ByteBuf propertiesBuf = pdmsg.getDurableProperties();
          HermesPrimitiveCodec codec = new HermesPrimitiveCodec(propertiesBuf);
          Map<String, String> propertiesMap = codec.readStringStringMap();
          sender.send(tpp.getTopic(), propertiesMap.get("pK"), bytes);
          BrokerStatusMonitor.INSTANCE.kafkaSend(tpp.getTopic());
        }
      }
    } finally {
      bodyBuf.release();
    }
  }
  protected void writeProperties(List<Pair<String, String>> properties, ByteBuf buf) {
    HermesPrimitiveCodec codec = new HermesPrimitiveCodec(buf);
    if (properties != null) {
      Map<String, String> map = new HashMap<String, String>();
      for (Pair<String, String> prop : properties) {
        map.put(prop.getKey(), prop.getValue());
      }

      codec.writeStringStringMap(map);
    } else {
      codec.writeNull();
    }
  }
 protected Map<String, String> readProperties(ByteBuf buf) {
   HermesPrimitiveCodec codec = new HermesPrimitiveCodec(buf);
   return codec.readStringStringMap();
 }