Consuming messages

Pull the bytes from your broker, decode them, gate with accepts, then switch on the URN — regardless of which language produced the message. traceId() carries the cross-service correlation id.

import com.babelqueue.*;

// body pulled from your broker (a Jedis BLPOP, an AMQP delivery, …)
Envelope in = EnvelopeCodec.decode(body);
if (EnvelopeCodec.accepts(in)) {
    switch (EnvelopeCodec.urn(in)) {
        case "urn:babel:orders:created" ->
            log.info("[{}] order received: {}", in.traceId(), in.data());
        default -> { /* unknown URN */ }
    }
}

That’s the whole loop: any producer, any consumer, one schema.