Introduction

Manage RabbitMQ structure of your virtual hosts. Similary to ActiveRecord schema.rb or structure.sql that dumps the current database schema, rabbitmq-schema will dump a db/rabbitmq_structure.json timestamped file with the representation of the virtual hosts, queues, exchanges, bindings, users and permissions.

Installation

Include this to your development/test Gemfile:

  gem 'rabbitmq-schema'

Usage

Make sure you set an environment variable for the rabbitmq api (you can add the /api path or leave it out):

RABBITMQ_MANAGEMENT_URL=http://guest:guest@localhost:15672

Create definition

Create a new vhost and definition for your application. It will create the vhosts of your choice and add permissions to the user in the environment variable to those vhosts.

  bundle exec rake rabbitmq:create             # It will ask you what vhosts to create the definition with
  # or
  bundle exec rake rabbitmq:create VHOSTS=hats # It will directly create a vhost named '/hats' 

Drop definition

Drop the vhosts in from your RabbitMQ instance and remove the file:

  bundle exec rake rabbitmq:drop

Dump definition

Dump the definition of the vhosts in your RabbitMQ instance into definition file:

  bundle exec rake rabbitmq:dump             # It will dump the vhosts specificed in the existing definition file
  # or 
  bundle exec rake rabbitmq:dump VHOSTS=hats # It will dump the specified vhost in a new definition few

Load definition

Load the vhosts definition from your definition file into your RabbitMQ instance:

  bundle exec rake rabbitmq:load

TODO

  • [ ] Make it Rails independent
    • [ ] There's a few uses of Hash#except.
    • [ ] There's a few uses of Hash#with_indifferent_access.
    • [ ] The Engine class should only be loaded when Rails is present.
    • [ ] User should be able to indicate the file path for the structure.
    • [ ] Rails dependency should be removed from gemspec.