0.0
No commit activity in last 3 years
No release in over 3 years
A light STOMP wrapper to ease interaction with a queueing system (e.g. ActiveMQ)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
~> 10.0
~> 3.1

Runtime

~> 1.3
 Project Readme

QueueWorker

A light STOMP wrapper to ease interaction with a queueing system (e.g. ActiveMQ)

Installation

Add this line to your application's Gemfile:

gem 'queue_worker'

And then execute:

$ bundle

Or install it yourself as:

$ gem install queue_worker

Usage

worker = QueueWorker.new('some_queue_name')
# Publish a message (will be serialized to JSON)
worker.push({ name: 'foo' }) 
# Specify the subscribe callback (message is automatically deserialized and ack'd)
worker.handler = proc { |args| puts "Got message #{args}" }
# Asynchronously subscribe to the queue
worker.subscribe 

Wait (synchronously) for a message to be received and acknowledged (ack'd) before continuing

worker.join

Remove the listener (thread) and closes the connection

worker.close

Alternatively, a block can be given to subscribe and the number of messages to fetch can be specified (default 1).

worker.subscribe(10) do |message|
  if message.command == 'MESSAGE'
    puts "Got message #{JSON.parse(message.body, symbolize_names: true)}"
  end
  worker.ack(message)
end

Contributing

  1. Fork it ( https://github.com/ridiculous/queue_worker/fork )
  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 a new Pull Request