exframe-mq is a messaging framework module providing a simplified abstraction layer over RabbitMQ for Node.js applications, currently stable at version 5.2.0. It is part of the broader exframe ecosystem and is typically used in conjunction with other exframe-* packages like exframe-context, exframe-health, and exframe-logger. The library primarily focuses on a Publish/Subscribe topology, makes a key assumption of JSON payloads for all messages, and manages persistent and shared connections to the RabbitMQ server. While a specific release cadence isn't detailed, its close ties to other exframe modules suggest coordinated releases. Key differentiators include its opinionated, simplified API for common RabbitMQ patterns and deep integration with the exframe application framework.
npm install exframe-mqVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize the `exframe-mq` module, configure a connection to RabbitMQ, create a messaging client, and then subscribe to and publish messages using a topic exchange topology.
Ensure all messages published through `exframe-mq` are valid JSON objects. If receiving messages from external, non-JSON sources, implement custom middleware to handle parsing or validation before `exframe-mq`'s default processing.
Install all listed peer dependencies at compatible versions (e.g., `npm install exframe-context@1 exframe-health@1 exframe-logger@3 exframe-service@1`). Ensure they are properly initialized and passed where required (e.g., `logger` in `mq.create()`).
Always explicitly configure the `url`, `maxAttempts`, `baseTimeout`, `heartbeat`, and `responseTimeout` in `mq.create()` for production deployments, ideally using environment variables.
Ensure all message processing functions passed to `client.subscribe` are `async` functions or explicitly return `Promise.resolve()` or `Promise.reject()`.
Provide a logger object that implements `info`, `error`, `warn`, and `debug` methods, or use an instance of `winston` (or a `winston`-compatible logger) directly.
Ensure the RabbitMQ server is running and accessible from the application's host. Verify the `url` configuration in `mq.create()` is correct.
Adjust your import statement to `import mq from 'exframe-mq';` (ESM) or `const mq = require('exframe-mq');` (CommonJS), then access the `create` method as `mq.create()`.Install the missing peer dependency using `npm install <package-name>@<version-range>` (e.g., `npm install exframe-logger@3`) to satisfy the requirement. Repeat for any other missing `exframe-*` peer dependencies.