public class UdpSensorReadingDecoder extends GenericSensorReadingDecoder implements QueueConsumer { public State initialize (Context context) { State state = new State (); super.initialize (context, state); state.packetsQueue = context.resolveQueue ("udp_sensor_reading_packets"); state.packetsConsumer = state.packetsQueue.registerConsumer (this); return state; } public void consumeMessage (State state, UdpPacket packet) { SensorReading reading = this.decode (packet); this.publish (state, reading); } protected SensorReading decode (UdpPacket request) { ... } public static class State extends GenericSensorReadingDecoder.State { public Queue packetsQueue; public QueueConsumer packetsConsumer; } }