
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
simple-queue-decorator
Advanced tools
by @foundernest
Simple decorator-based wrapper for easy RabbitMQ queuing.
Both JavaScript and Typescript can be used, however, this library takes advantage of Typescript decorators. OnQueue decorator is only available using Typescript.
A running instance of RabbitMQ is needed, a docker-compose file is provided to use along with this library in a dev env (
docker-compose up -d rabbitmq). Do not use the given image in production
Init the service:
import * as SimpleQueueDecorator from 'simple-queue-decorator'
await SimpleQueueDecorator.init({
url: "127.0.0.1",
user: "guest",
password: "guest"
})
await SimpleQueueDecorator.close(); // Closes the service
Consume Messages (this can be done before init):
import { OnQueue } from 'simple-queue-decorator'
class MyConsumer {
@OnQueue('my-queue')
public static async onMessageReceived(msg: any) {
console.log("Message Received", msg.foo)
await doSomethingWithMyMsg(msg) // If this returns a rejected promise, message will be re-queued once
}
}
It is recommended to use static methods with queue decorator
Send Messages (Service must be initiated beforehand):
import * as SimpleQueueDecorator from 'simple-queue-decorator'
SimpleQueueDecorator.sendMessage('my-queue', {foo: "my message name"})
Messages can also be listened without using the decorator:
import * as SimpleQueueDecorator from 'simple-queue-decorator'
SimpleQueueDecorator.registerQueue("my-queue", async (msg) => {
console.log("Message Received", msg.foo)
await doSomethingWithMyMsg(msg)
})
This is preferable if using JavaScript or using dynamic dependencies (e.g. injectables) in the queue callback. RegisterQueue also support an array of queues, the callback will be execute for any message in any of those queues.
Send a message with priority:
import * as SimpleQueueDecorator from 'simple-queue-decorator'
SimpleQueueDecorator.sendMessage('my-queue',
{foo: "my message name"},
{
priority: SimpleQueueDecorator.MessagePriority.HIGH
});
Messages will be ordered and received according to priority. Priority can be LOW, MEDIUM or HIGH, a number ranging from 1 to 10 can also be used. Keep in mind the following:
LOW)The following options can be passed to init:
init, if 0, it will attempt indefinitely. Defaults to 0.node and npm required, either docker or a running instance of rabbitmq required.
npm installnpm run tsc to compiledocker-compose up -d rabbitmq to launch rabbitmqnpm test to compile and execute tests (rabbitmq must be running)This library makes several assumptions on how the messages are going to be consumed, as such, if your needs are different, we recommend directly using amqplib.
FAQs
A simple interface with RabbitMQ through typescript decorators
We found that simple-queue-decorator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.