0.3.10 • Published 5 years ago
rxamqp v0.3.10
Reactive AMQP

This library is aimed to ease amqplib usage.
Installation:
npm i rxamqp -S
Following features are implemented:
- Client reconnection
- Failed channel reopening
- Express like middleware pipelines for subscriptions
- Promise based querying interface
Usage example
const createClient = require('rxamqp')
const client = createClient()
// prepare reply queues beforehand to save request time later
client.assertReplyQueue('foo.bar')
client.assertReplyQueue('foo.bar.error.sync')
client.assertReplyQueue('foo.bar.error.async')
client
// middlewares bound to specific routing keys and exchange
.use(
{ exchange: 'amq.topic', routingKey: 'foo.bar' }, (msg, ctx, next) => {
ctx.value = 1
return next()
}, (msg, ctx, next) => {
ctx.value++
return next()
}
)
.use(
{ exchange: 'amq.topic', routingKey: 'foo.bar.error.sync' }, (msg, ctx, next) => {
ctx.value = 1
throw new Error('Some sync Error')
return next()
}, (msg, ctx, next) => {
ctx.value++
return next()
}
)
.use(
{ exchange: 'amq.topic', routingKey: 'foo.bar.error.async' }, (msg, ctx, next) => {
ctx.value = 1
setTimeout(() => {
next(new Error('Some async Error'))
}, 0)
}, (msg, ctx, next) => {
ctx.value++
return next()
}
)
// global middleware
.use((msg, ctx, next) => {
return ctx.respond({ foo: `${msg.bar} - ${ctx.value}` })
})
// global error handler
.use((error, msg, ctx, next) => {
ctx.rejectAndRespond({ foo: `${msg.bar} - ${ctx.value}`, error: error.message })
next()
})
client.listen()
client.request('amq.topic', 'foo.bar', { bar: 'bar' })
.then(result => console.log(result))
/*
{
"data": {
"foo": "bar - 2"
}
}
*/
client.request('amq.topic', 'foo.bar.error.sync', { bar: 'bar' })
.catch(result => console.log(result))
/*
{
"data": {
"foo": "bar - 1",
"error": "Some sync Error"
}
}
*/
client.request('amq.topic', 'foo.bar.error.async', { bar: 'bar' })
.catch(result => console.log(result))
/*
{
"data": {
"foo": "bar - 1",
"error": "Some async Error"
}
}
*/
Roadmap
- Add primary global middlwares that are executed before all subscribers' local ones
- Improve documentation
0.3.8
5 years ago
0.3.7
5 years ago
0.3.9
5 years ago
0.3.10
5 years ago
0.3.6
5 years ago
0.3.5
5 years ago
0.3.4
5 years ago
0.3.3
5 years ago
0.3.2
5 years ago
0.3.0
5 years ago
0.3.1
5 years ago
0.2.14
5 years ago
0.2.13
5 years ago
0.2.12
5 years ago
0.2.11
5 years ago
0.2.10
5 years ago
0.2.9
5 years ago
0.2.8
5 years ago
0.2.7
6 years ago
0.2.6
6 years ago
0.2.5
6 years ago
0.2.3
6 years ago
0.2.2
6 years ago
0.2.1
6 years ago
0.2.0
6 years ago
0.0.22-queue
6 years ago
0.0.21-queue
6 years ago
0.0.20-queue
6 years ago
0.1.7
7 years ago
0.0.21
7 years ago
0.1.5
7 years ago
0.1.4
7 years ago
0.1.3
7 years ago
0.1.2
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago
0.0.20
7 years ago
0.0.19
7 years ago
0.0.18
7 years ago
0.0.17
7 years ago
0.0.16
7 years ago
0.0.15
7 years ago
0.0.14
7 years ago
0.0.13
7 years ago
0.0.12
7 years ago
0.0.11
7 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.1
7 years ago