Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/combatpoodle/simple-message-helper
Implements a simple message broker pattern for subscriptions to a single queue and publication to a single command.
https://github.com/combatpoodle/simple-message-helper
Last synced: 10 days ago
JSON representation
Implements a simple message broker pattern for subscriptions to a single queue and publication to a single command.
- Host: GitHub
- URL: https://github.com/combatpoodle/simple-message-helper
- Owner: combatpoodle
- Created: 2015-06-03T03:32:40.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-18T13:55:53.000Z (over 9 years ago)
- Last Synced: 2024-04-26T01:21:24.649Z (8 months ago)
- Language: CoffeeScript
- Size: 156 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Message Helper
This simplifies interactions for working with a message broker when you really don't need a full feature set - basically just send and receive. It's written in CoffeeScript and is used downstream to run chatops tasks as part of a Hubot deployment.
### Basic usage
```javascript
var readyFn = function() {
console.log("Connected and configured");communicator.send("Do stuff");
};var messageHandler = function(message) {
console.log("Got a message:", message);
};var disconnected = function() {
console.log("Disconnected");
}var messageHelper = require('message-helper')
var communicator = new messageHelper(readyFn, messageHandler, disconnected);
```From the above, you'd expect the message "Do stuff" to get published to your exchange.
### Configuration
You can use the default configuration:
```coffeescript
configuration =
user: "guest"
password: "guest"
host: "localhost"
port: 5672
vhost: "/"
commandExchangeName: "hubot-commands"
commandRoutingKey: "hubot-commands"
responseExchangeName: "hubot-responses"
responseQueueName: "hubot-responses"
```Or, use custom environment variables:
```bash
export AMQP_USER="amqp_user"
export AMQP_PASSWORD="amqp_password"
export AMQP_HOST="amqp_host"
export AMQP_PORT="amqp_port"
export AMQP_VHOST="amqp_vhost"
export AMQP_COMMAND_EXCHANGE_NAME="amqp_command_exchange_name"
export AMQP_COMMAND_ROUTING_KEY="amqp_command_routing_key"
export AMQP_RESPONSE_EXCHANGE_NAME="amqp_response_exchange_name"
export AMQP_RESPONSE_QUEUE_NAME="amqp_response_queue_name"
```