Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@babelqueue/nestjs

npm

Polyglot Queues, Simplified. A NestJS adapter for BabelQueue: an injectable publisher (over BullMQ) that emits the canonical BabelQueue envelope, so NestJS services interoperate with the PHP/Laravel, Python, Go, Java and .NET SDKs.

npm install @babelqueue/nestjs @nestjs/common bullmq

Register the module

import { Module } from "@nestjs/common";
import { BabelQueueModule } from "@babelqueue/nestjs";

@Module({
  imports: [
    BabelQueueModule.forRoot({
      queue: "orders",
      connection: { host: "localhost", port: 6379 },
    }),
  ],
})
export class AppModule {}

Produce

import { Injectable } from "@nestjs/common";
import { BabelQueuePublisher } from "@babelqueue/nestjs";

@Injectable()
export class Orders {
  constructor(private readonly babelQueue: BabelQueuePublisher) {}

  create() {
    return this.babelQueue.publish("urn:babel:orders:created", { order_id: 1042 });
  }
}

Consume

Build a BullMQ worker with the re-exported processor (URN routing):

import { Worker } from "bullmq";
import { processor } from "@babelqueue/nestjs";

new Worker("orders", processor({
  "urn:babel:orders:created": async (env) => { /* ... */ },
}), { connection: { host: "localhost", port: 6379 } });

OpenTelemetry tracing (ADR-0028)

BabelQueuePublisher.publish(urn, data, { headers }) accepts the out-of-band HeaderCarrier produced by @babelqueue/core/otel's publish (e.g. a W3C traceparent) and threads it through to the underlying @babelqueue/bullmq job's native telemetry.metadata slot — the canonical envelope is never touched. Consume with the re-exported processor, whose handler receives the carried headers as its third argument, so the core's otel wrapHandler links the consumer span as a true child of the producer span. Requires @babelqueue/core@^1.4.0.

License

MIT © Muhammet Şafak · babelqueue.com