Nodeamqp provides an opinionated way of using RabbitMQ for event-driven architectures.
Add the dependency
yarn add @opzkit/nodeamqp
See the 'examples' subdirectory.
TODO
- Official ampq documentation
MIT - see LICENSE for more details.
TODO
yarn run test
An example message logger which dumps messages to console.
const StdOutMessageLogger = (
content: Buffer,
routingKey: string,
outgoing: boolean
) => {
let out: string = content.toString("utf-8");
try {
out = JSON.stringify(JSON.parse(out), null, 2);
} catch (e) {
// Ignore errors since out is already set
}
if (outgoing) {
console.log(
`Sending using routingkey: '${routingKey}' with content:\n${out}\n`
);
} else {
console.log(
`Received from routingkey '${routingKey}' with content:\n${out}\n`
);
}
};