Socket
Book a DemoInstallSign in
Socket

simple_rabbit

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple_rabbit

1.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

SimpleRabbit

Simple utility to send / consume messages via RabbitMQ, based on ruby-amqp/bunny ruby gem.

Installation

Add this line to your application's Gemfile:

gem 'simple_rabbit'

And then execute:

$ bundle install

Or install it manually:

$ gem install simple_rabbit

Usage

Establishing connection:

To establish connection run this once. It can go to any kind of initializer script.

SimpleRabbit::Connection.get(user: "rabbitmquser", pass: "rabbitpass", host: "localhost:5672")

It accepts all configuration params available in Bunny gem.

Publishing message

Once connection has been established you can run following to publish message to queue called 'sample_queue'.

SimpleRabbit::Publisher.publish("sample_queue", "This is the message body")

It creates durable queue, that gets initialized on demand.

Creating consumer worker

To create consumer worker that reacts to messages published in 'sample_queue' define worker as below:

SimpleRabbit::ConsumerWorker.run("sample_queue") do |message|
  puts "Hey I've received message with body: '#{message}'"
  # do sth
end

All workers are set to use manual acknowledgement, so in other words if worker fails with some sort of exception, the message can be handled by different worker.

FAQs

Package last updated on 10 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.