Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

moleculer-amqp-queue

0.0.1 • Public • Published

Moleculer logo

moleculer-amqp-queue NPM version

Task queue mixin for AMQP.

Install

$ npm install moleculer-amqp-queue --save

Usage

Create queue worker service

const AMQPMixin = require("moleculer-amqp-queue");
 
broker.createService({
    name: "task-worker",
    mixins: [AMQPMixin()],
    AMQPQueues: {
        "sample.task" (channel, msg) {
            let job = JSON.parse(msg.content.toString());
            this.logger.info("New job received!", job.id);
            setTimeout(() => {
                channel.ack(msg);
            }, 500);
        }
    }
});

Create job in service

const QueueService = require("moleculer-amqp-queue");
 
broker.createService({
    name: "job-maker",
    mixins: [QueueService()],
    methods: {
        sampleTask(data) {
            const job = this.addAMQPJob("sample.task", data);
        }
    }
});

Test

$ npm test

In development with watching

$ npm run ci

License

The project is available under the MIT license.

Contact

Copyright (c) 2016-2018 MoleculerJS

@moleculerjs @MoleculerJS

Install

npm i moleculer-amqp-queue

DownloadsWeekly Downloads

7

Version

0.0.1

License

MIT

Unpacked Size

14.1 kB

Total Files

12

Last publish

Collaborators

  • avatar