Repository is archived
No release in over 3 years
Low commit activity in last 3 years
Gem to build Event Hub processors
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.12.5
>= 11.2.2
>= 3.7.0
~> 3.7.0

Runtime

>= 1.6.0
>= 2.0.0
>= 2.1.5
 Project Readme

Gem Version Maintainability Test Coverage ci

Important information from 2022-07-27

This component has been replaced by https://github.com/thomis/eventhub-processor2 and will no longer be maintained. Please upgrade to new processor2 gem.

eventhub-processor

Gem to build Event Hub Processors. It gives you some core infrastructure pieces to easily implement a customized Event Hub Processor.

Installation

Add this line to your application's Gemfile:

gem 'eventhub-processor'

And then execute:

$ bundle

Or install it yourself as:

$ gem install eventhub-processor

Usage

The easiest way to cretae a new processor is to use the eventhub-command gem. Run

eh generate_processor --help

for details.

Code

# define a class and derive it from Eventhub::Processor
module EventHub
  class PlateStoreRouter < Processor
    # this is the method to deal with the message
    def handle_message(metadata,payload)
      puts payload
    end
  end
end

# load configuration file if required and start your processor
config_file = ['config',"#{File.basename(__FILE__,'.rb')}.json"].join('/')
EventHub::Configuration.instance.load_file(config_file,environment)

# create instance of your processor and start it
EventHub::PlateStoreRouter.new.start

Arguments

You can use the default argument parser behaviour (-e, -d, -h) or extend it like:

parsed = EventHub::ArgumentParser.parse(['-x']) do |parser, options|
  parser.on('-x') do
    options.x = 'secret switch selected'
  end
end

Configuration

Configuration with minimal settings

  {
    "development": {
      "processor": {
        "listener_queues": ["component_queue"]
      }
    }
  }

Configuration with SSL/TLS. Values shown for host, port, management_port, user, password, and vhost are the defaults. Default for ssl is false.

  {
    "development": {
      "server": {
        "host": "localhost",
        "port": 5672,
        "management_port": 15672,
        "user": "admin",
        "password": "admin",
        "vhost": "event_hub",
        "ssl": true
      },
      "processor": {
        "listener_queues": ["component_queue"]
      }
    }
  }

Configuration with SSL/TLS for rest calls but amqp (disabled amqps).

  {
    "development": {
      "server": {
        "host": "localhost",
        "port": 5672,
        "management_port": 15672,
        "user": "admin",
        "password": "admin",
        "vhost": "event_hub",
        "ssl": {
          "amqps": false
        }
      },
      "processor": {
        "listener_queues": ["component_queue"]
      }
    }
  }

Configuration with custom SSL/TLS

  {
    "development": {
      "server": {
        "host": "localhost",
        "port": 5672,
        "management_port": 15672,
        "user": "admin",
        "password": "admin",
        "vhost": "event_hub",
        "ssl": {
          "client_cert": "/path/client_cert.pem",
          "client_key": "/path/client_key.pem",
          "ca_cert": "/path/ca_cert.pem"
        }
      },
      "processor": {
        "listener_queues": ["component_queue"]
      }
    }
  }

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request