0.0.2 • Published 5 months ago

@mqueue/queue v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

mqueue (Multi-Queue)

Simple queue interface with support for multiple backends. Keep your options open.

Installation

Install MQueue and select adapters:

# Install MQueue:
npm install --save @mqueue/queue # + Adapter(s)...
# or use pnpm/yarn

# Install some adapters
npm install --save @mqueue/amqplib
npm install --save @mqueue/azure-service-bus
npm install --save @mqueue/rhea
npm install --save @mqueue/sqs
npm install --save @mqueue/mqtt
npm install --save @mqueue/kafkajs
npm install --save @mqueue/stompjs
npm install --save @mqueue/fastq
const outgoingQueue = new MQueue.Outgoing(
  await AmqplibOutgoingQueue.connect("amqp://rabbitmq:5271", "queue-name"),
);

outgoingQueue.sendMessage({
  headers: {
    "Account-ID": "123",
  },
  body: "...",
});

// ...

const incomingQueue = new MQueue.Incoming(
  await AmqplibIncomingQueue.connect("amqp://rabbitmq:5271", "queue-name"),
);
// Example: Switching between AMQP v0.9.1 and SQS for live and production
const isProduction = process.env.NODE_ENV === "production";

const outgoingQueue = new MQueue.Outgoing(
  isProduction
    ? await AmqplibOutgoingQueue.connect("amqp://rabbitmq:5271", "queue-name")
    : await SQSOutgoingQueue.connect("amqp://rabbitmq:5271", "queue-name"),
);

outgoingQueue.sendMessage({
  headers: {
    "Account-ID": "123",
  },
  body: "...",
});

// ...

const incomingQueue = new MQueue.Incoming(
  isProduction
    ? await AmqplibIncomingQueue.connect("amqp://rabbitmq:5271", "queue-name")
    : await SQSIncomingQueue.connect("amqp://rabbitmq:5271", "queue-name"),
);

Queue Adapters

Broadcast Strategies

Compatibility

Why might you need a Message Queue?

  • NodeJS v18+, tested on v22+
Queue PlatformQueue Adapter
Apache ActiveMQ (AMQP v1.0)@mqueue/rhea
Apache ActiveMQ (MQTT)@mqueue/mqtt
Apache ActiveMQ (STOMP)@mqueue/stompjs
Apache Kafka@mqueue/kafkajs
AWS Simple Queue Service (SQS)@mqueue/sqs
Azure Service Bus@mqueue/azure-service-bus
Azure Service Bus (AMQP v1.0)@mqueue/rhea
Eclipe Mosquitto@mqueue/mqtt
ElasticMQ (SQS-Compatible)@mqueue/sqs
Fastq@mqueue/fastq
RabbitMQ (AMQP v0.9.1)@mqueue/amqplib
RabbitMQ (AMQP v1.0 or with AMQP v1.0 Plugin)@mqueue/rhea
RabbitMQ (with MQTT Plugin)@mqueue/mqtt
RabbitMQ (with STOMP Plugin)@mqueue/stompjs
0.0.2

5 months ago

0.0.1

5 months ago