@Override
public void filterWrite(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception {
Object message = writeRequest.getMessage();
ProtocolEncoder encoder = getEncoder(session);
ProtocolEncoderOutput encoderOut = new DirectOutput(session, nextFilter, writeRequest);
try {
encoder.encode(session, message, encoderOut);
nextFilter.filterWrite(session, new EndOfMessage(writeRequest));
} catch (ProtocolEncoderException e) {
throw e;