https://github.com/ninech/amqp_helpers
Simple helpers to achieve various AMQP tasks.
https://github.com/ninech/amqp_helpers
Last synced: 11 days 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 (about 11 years ago)
- Default Branch: master
- Last Pushed: 2017-01-05T15:59:02.000Z (over 8 years ago)
- Last Synced: 2025-06-26T16:59:30.322Z (19 days ago)
- Language: Ruby
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 26
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# amqp_helpers [](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
```