code: @Override
      public ChannelBuffer buffer() throws Exception {
          ChannelBufferOutputStream bout = new ChannelBufferOutputStream(ChannelBuffers.directBuffer(encodedLength));
  
          for (Object msg : msgs)
              if (msg instanceof TaskMessage)
                  writeTaskMessage(bout, (TaskMessage) msg);
              else {
                  // LOG.debug("Write one non-TaskMessage {}", msg );
                  ((ControlMessage) msg).write(bout);
              }
  
          // add a END_OF_BATCH indicator
          ControlMessage.EOB_MESSAGE.write(bout);
          // LOG.debug("ControlMessage.EOB_MESSAGE " );
  
          bout.close();
  
          return bout.buffer();
      }
docs: create a buffer containing the encoding of this batch