Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ninech/amqp_helpers
Simple helpers to achieve various AMQP tasks.
https://github.com/ninech/amqp_helpers
Last synced: about 1 month ago
JSON representation
Simple helpers to achieve various AMQP tasks.
- Host: GitHub
- URL: https://github.com/ninech/amqp_helpers
- Owner: ninech
- License: mit
- Created: 2014-05-23T11:35:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-05T15:59:02.000Z (almost 8 years ago)
- Last Synced: 2024-10-31T13:13:16.994Z (about 2 months ago)
- Language: Ruby
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 27
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# amqp_helpers [![Build Status](https://travis-ci.org/ninech/amqp_helpers.svg)](https://travis-ci.org/ninech/amqp_helpers)
Simple utilities to achieve various AMQP tasks.
## Daemon
`AMQPHelpers::Daemon` allows you to build a simple message consumer.
### Example
``` ruby
AMQPHelpers::Daemon.new({
name: 'nba-scores-daemon',
environment: 'production',
logger: PXEConfGen.logger,
connection_params: {
host: 'localhost',
port: 5672
},
queue_params: { durable: false },
exchanges: {
'nba.scores': {
params: {
type: :topic,
durable: false
},
bindings: [
{ routing_key: 'north.#' },
{ routing_key: 'south.#' }
]
}
}
}).start do |delivery_info, payload|
puts "AMQP Incoming message #{payload}"
end
```## Publisher
`AMQPHelpers::Publisher` allows you to publish an AMQP message in an easy way.
### Example
It takes the same configuration hash as the daemon does.
* First argument of publish is the payload which will be JSON encoded.
* Second arugment specifies the exchange configuration which should be used.
* Third argument defines the routing key.```ruby
publisher = AMQPHelpers::Publisher.new({
name: 'nba-scores-daemon',
environment: 'production',
logger: PXEConfGen.logger,
connection_params: {
host: 'localhost',
port: 5672
},
queue_params: { durable: false },
exchanges: {
'nba.scores': {
params: {
type: :topic,
durable: false
},
bindings: [
{ routing_key: 'north.#' },
{ routing_key: 'south.#' }
]
}
})publisher.publish('1:1', 'nba.scores', 'south.east') # => true
```