--- title: "Consuming messages" description: "Consuming messages — Node.js BabelQueue SDK (1.x)." source: https://babelqueue.com/docs/babelqueue-node/1.x/consuming-messages/ updated: 2026-06-06T00:00:00.000Z --- # Consuming messages Pull the bytes from your broker, `decode` them, gate with `accepts` (a TypeScript type guard), then switch on the URN — regardless of which language produced the message. `trace_id` carries the cross-service correlation id. ```ts import { EnvelopeCodec } from "@babelqueue/core"; // body pulled from your broker (Redis BLPOP, an AMQP message, …) const incoming = EnvelopeCodec.decode(body); if (EnvelopeCodec.accepts(incoming)) { // `incoming` is now narrowed to a fully-typed Envelope switch (EnvelopeCodec.urn(incoming)) { case "urn:babel:orders:created": console.log(`[${incoming.trace_id}] order received`, incoming.data); break; } } ``` That's the whole loop: any producer, any consumer, one schema.