
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
foundernest-amqp-client
Advanced tools
A TypeScript-based AMQP client designed to work with RabbitMQ and provides functionalities for connecting to the broker, sending messages, and consuming messages with support for dead-letter queues and reconnection strategies.
To install the package, use npm or yarn:
npm install foundernest-amqp-client
yarn add foundernest-amqp-client
Create an instance of AMQPClient
by providing connection options and, optionally, a custom logger:
Example:
import { AMQPClient } from 'foundernest-amqp-client';
const myLogger = new MyLogger()
const client = new AMQPClient({
options: {
host: 'localhost',
username: 'guest',
password: 'guest',
logger: myLogger,
}
});
To send a message to a queue, use the sendMessage
method:
Example:
await client.sendMessage('test-queue', { key: 'value' });
You can send headers and a correlation id along with the message:
await client.sendMessage('test-queue', data, {
correlationId: 1234
headers: {
key: 'value'
},
}
);
To create a listener for a queue, use the createListener
method. This method sets up the necessary queue and binds it to a dead-letter queue if specified. Ensure that the connection is established before starting to consume messages:
Example:
const client = new AMQPClient(config);
await client.createListener('test-queue', async (message) => {
checkAuth(message.headers)
processMessage(message.content);
});
You don't need to explicitly connect to the broker, each time a listener is created a connection will be created if needed.
If the connection to the broker is lost, the client will attempt to reconnect using a exponential backoff strategy.
To close the AMQP connection and channel, call the close
method:
Example:
await client.close();
host
: The hostname of the AMQP broker.port
: The port of the AMQP broker (default: 5672).username
: The username for authentication.password
: The password for authentication.vhost
: The virtual host to connect to (default: '/').You can provide a custom logger that implements the methods debug
, info
, warn
, and error
. By default, the client's logging will use the console.
This project uses Vitest for testing. To run the tests, use the following command:
npm test
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
This README provides an overview of your AMQP client, including installation instructions, usage examples, configuration options, and information on testing and contributing. Feel free to customize it further based on your specific requirements.
FAQs
AMQP Client
The npm package foundernest-amqp-client receives a total of 56 weekly downloads. As such, foundernest-amqp-client popularity was classified as not popular.
We found that foundernest-amqp-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.