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.
using BabelQueue;
// body pulled from your broker (a StackExchange.Redis pop, an AMQP delivery, …)
var incoming = EnvelopeCodec.Decode(body);
if (EnvelopeCodec.Accepts(incoming))
{
switch (EnvelopeCodec.Urn(incoming))
{
case "urn:babel:orders:created":
logger.LogInformation("[{Trace}] order received: {Data}", incoming.TraceId, incoming.Data);
break;
}
}
That’s the whole loop: any producer, any consumer, one schema.