code: @Override
      public ChannelBuffer buffer() throws Exception {
          int payloadLen = 0;
          if (_message != null)
              payloadLen = _message.length;
  
          int totalLen = 8 + payloadLen;
          ChannelBufferOutputStream bout = new ChannelBufferOutputStream(ChannelBuffers.directBuffer(totalLen));
          bout.writeShort(_type);
  
          if (_task > Short.MAX_VALUE)
              throw new RuntimeException("Task ID should not exceed " + Short.MAX_VALUE);
  
          bout.writeShort((short) _task);
          bout.writeInt(payloadLen);
          if (payloadLen > 0)
              bout.write(_message);
  
          bout.close();
          return bout.buffer();
      }
docs: create a buffer containing the encoding of this batch