Fastify AMQP connection plugin wrapper to amqplib, to use with RabbitMQ
This is a Node.js module available through the
npm registry. It can be installed using the
npm
or
yarn
command line tools.
npm install fastify-amqp --save
npm install
npm test
const fastify = require('fastify')()
fastify.register(require('fastify-amqp'), {
host: 'localhost',
// the default value is 5672
port: 5672,
// the default value is guest
user: 'guest',
// the default value is guest
pass: 'guest'
// the default value is empty
vhost: ''
url: 'amqps://xhdyuetsj:[email protected]/xhdyuetsj'
// url will override the options above, default: undefined
decorateRequest: false
// default: false
})
fastify.get('/', function (request, reply) {
const channel = this.amqpChannel
const queue = 'hello'
const msg = 'Hello world'
channel.assertQueue(queue, {
durable: false
})
channel.sendToQueue(queue, Buffer.from(msg))
reply.send(' [x] Sent ' + msg)
})
fastify.listen(3000, err => {
if (err) throw err
})
This plugin is just a wrapper to amqplib.
Contains:
- amqplib: An AMQP 0-9-1 (e.g., RabbitMQ) library and client.
- fastify-plugin: Plugin helper for Fastify
- fastify: Fast and low overhead web framework, for Node.js
- pre-commit: Automatically install pre-commit hooks for your npm modules.
- standard: JavaScript Standard Style
- tap: A Test-Anything-Protocol library for JavaScript
- typescript: TypeScript is a language for application scale JavaScript development
MIT