@Override
    protected void encode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
        if (msg != null) {
            for (EventListener listener : listeners) {
                if (listener instanceof MessageExchangeListener) {
                    ((MessageExchangeListener) listener).sending(msg);
                }
            }
        }
        out.add(msg);
    }
Codec which propagate received or sent messages to connection event listeners.
plc4j/spi/src/main/java/org/apache/plc4x/java/spi/EventListenerMessageCodec.java