ladle
v0.0.0
Published
Node.js implementation of RabbitMQ's shovel client.
Readme
ladle
A Node.js implementation of RabbitMQ's shovel client.
What it is
RabbitMQ comes with a programmable AMQP client (the Shovel plugin) that picks up messages from one or more source brokers and drops them off in one or more destination brokers. Ladle provides the same functionality as RabbitMQ's shovel plugin, but as a standalone Node.js implementation.
What it does
Ladle acts as a bridge between two or more AMQP brokers. It picks up messages from one or more source brokers and drops off them off at one or more destination brokers.
Features
- [x] Basic message pumping.
- [ ] SSL.
- [ ] Pre-startup declarations.
- [ ] JSON-based configuration.
- [ ] Standalone systemd service.
- [ ] Use it as part of your program.
How to use
As a dependency
If you want to use ladle as part of your own program, you can use npm to install it and automatically add to your
list of dependencies:
npm install --save ladleThen you can copy and paste this example into your code and adjust the configuration as appropriate:
var ladle = require("ladle");
var myLadle = ladle.create({
ladleName: "test",
sources: {
brokers: [ "amqp://user1:user1@host1" ],
declarations: []
},
destinations: {
brokers: [ "amqp://user2:user2@host2" ],
declarations: []
},
queue: "myWorkQueue",
publishFields: {
exchange: "my_direct",
routingKey: "from_ladle"
}
});
myLadle.setRunning(true);This will create and start a ladle named test that will
- Connect to the AMQP broker running on
host1using the usernameuser1and passworduser1as the credentials. - Connect to the AMQP broker running on
host2using the usernameuser2and passworduser2as the credentials. - Consume messages from the queue named
myWorkQueueonhost1. - Re-publish messages in the exchange named
my_directwith the rouing keyfrom_ladle.
As a standalone application
If you want to use ladle as a standalone application, you can use npm to install it globally instead:
npm install -g ladleThen you have to create a configuration file at /etc/ladle/ladle.conf. You can use one of the provided example
configurations for simpler setup. The file is a JSON document mirroring the configuration you saw above in the usage
example. The ladle configuration lets you create one or more ladles at a time.
[ { ladleName: "test",
sources: {
brokers: [ "amqp://user1:user1@host1" ],
declarations: []
},
destinations: {
brokers: [ "amqp://user2:user2@host2" ],
declarations: []
},
queue: "myWorkQueue",
publishFields: {
exchange: "my_direct",
routingKey: "from_ladle"
} } ]This creates a ladle just as above.
Ladle configuration
ladleNamethe name of the ladle. (required)sourcesthe source brokers, ie. where messages are consumed. (required)brokersan array of AMQP URIs in string form. (required)declarationsan array of AMQP methods to be run on each broker after the ladle has established a connection to the source brokers. Defaults to none. (optional)
destinationsthe destination brokers, ie. where messages are re-published. (required)brokersan array of AMQP URIs in string form. (required)declarationsan array of AMQP methods to be run on each broker after the ladle has established a connection to the destination brokers. (optional)
queue: the name of the message queue to consume messages from. (required)prefetchCount: number of messages to prefetch and keep in-flight between brokers. Defaults to 1000. (optional)ackMode: How consumed messages are acknowledged. Defaults toonConfirm. (optional)publishProperties: Properties set on the basic.properties on each re-published message. (optional)addForwardHeaders: Iftrue, anx-ladledheader is appended or added to the message. Defaults tofalse. (Optional)publishFields: Fields set on the basic.publish method. By default, messages are re-published using the original exchange name and routing key. (Optional)reconnectDelay: the number of seconds to wait before reconnecting. Defaults to 1.5s. (Optional)
How to contribute
Code style
Ladle source code largely follows the Crockford style guide with the following exceptions:
- Line length is extended to 120 characters.
- Semicolon insertion might as well not exist.
- Variables are defined when they're needed, not at the top of a function.
Contributions
Please read the following before you're contributing:
By contributing to this project, you, the contributor, assign the copyright of your contribution, including but not restricted to source code and documentation, to me, Chris Eineke. In return, I grant you a world-wide, non-exclusive, royalty-free and perpetual right to use, copy, modify, communicate and make available to the public (including without limitation via the Internet) and distribute, in each case in an original or modified form, the contribution as you wish. If that hasn't scared you off, fork this repo and create a pull request. If you are contributing code, you must provide a passing unit test or must make appropriate changes to existing unit tests. Don't forget to add yourself to the
contributorsinpackage.json.
