title: How can I access a Netty Handler method from outside of the normal flow
body: <p>I am trying to integrate Netty (version 3.6.1.final) into our current system so I can replace the current NIO code.</p>
  
  <p>Currently we have a messaging Bus where events are queued for other listeners to process and put another event back on the bus for further processing.</p>
  
  <p>In my Netty business logic handler's  messageReceived() method, I will be adding an Input Request to the bus.   One thing I will be passing is the data from the Netty event message.</p>
  
  <p>I figure that I should pass the ChannelHandlerContext in this InputEvent along with the data/message received.  So that eventually when the OutputEvent is processed, It can use the ChannelHandlerContext that was originally passed around to send the processed data back to the requesting client on the correct Netty Channel.</p>
  
  <p>So how can the Output task that is processing the OutputEvent tie back into Netty?</p>
  
  <p>Do I issue some call using the ChannelHandlerContext I have using as input the processed data.  I don't want to tie up the Output task.</p>
  
  <p>Code snippet from Netty handler.</p>
  
  <pre><code>public void messageReceived(
          ChannelHandlerContext ctx, MessageEvent e) {
  
      byte[] message = (byte[])e.getMessage();
  
      try {
              data.add(message);
          }
      catch( IOException ioe )
          {
              logger.error(ioe);
          }
  
      InputEvent ie = new InputEvent( ctx, this, data.getBuffer() );
  
      try {
                bus.enqueue(ie);
      }
      catch( Exception ex )
     {
        logger.error(ex);
     }
  </code></pre>
  
  <p>Code snippet from Output processor.         </p>
  
  <pre><code>public void run() {
  
  
      // note that the OutputEvent (event) is available here.  This is not a Netty event.
      ChannelHandlerContext ctx = event.getHandlerContext();
      ClientChannel handler = event.getHandler();
  
      // I need to send the data in event.getBuffer() back.
  
  // Now what do I do here???
  
  
  …
  …
  …
  
  }
  </code></pre>
  
  <p>Thank you.</p>