0.0
No commit activity in last 3 years
No release in over 3 years
Simple helpers to achieve various AMQP tasks.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.3
~> 2.14

Runtime

~> 1.3
~> 1.4.1
~> 1.5
 Project Readme

amqp_helpers Build Status

Simple utilities to achieve various AMQP tasks.

Daemon

AMQPHelpers::Daemon allows you to build a simple message consumer.

Example

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.
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