OnStomp
A client-side ruby gem for communicating with message brokers that support
the STOMP 1.0 and 1.1 protocols. This gem was formerly known as stomper
,
but that name has been dropped because a
python stomp library by the same name
already existed. Also, I think "OnStomp" better expresses the event-driven
nature of this gem.
Installing
The OnStomp gem can be installed as a standard ruby gem:
gem install onstomp
Alternatively, you can clone the source through github.
Example Usage
# A simple message producer
client = OnStomp.connect('stomp://user:[email protected]')
client.send('/queue/onstomp-test', 'hello world')
client.disconnect
# A simple message consumer
client = OnStomp::Client.new('stomp+ssl://broker.example.org:10101')
client.connect
client.subscribe('/queue/onstomp-test', :ack => 'client') do |m|
client.ack m
puts "Got and ACK'd a message: #{m.body}"
end
while true
# Keep the subscription running until the sun burns out
end
Motivation
There is a STOMP client gem named stomp, so why create another gem? OnStomp was designed around giving users more control over how STOMP frames are handled through an event-driven interface. All IO reading and writing is performed through the use of non-blocking methods in the hopes of increasing performance.
The stomp
gem is a good gem that works well, I just desired a different
style API for working with message brokers.
Further Reading
License
OnStomp is covered by the Apache License 2.0. See the full LICENSE for details.
Thanks
There are a few people/groups I'd like to thank for helping me with the creation of this gem.
- Lionel Cons for the good suggestions while I was implementing support for the STOMP 1.1 spec. Check out his Perl client Net::STOMP::Client
- Brian McCallister, Johan Sørensen, Guy M. Allard and Thiago Morello for
their work on the
stomp
gem which introduced me to the STOMP protocol. - Hiram Chino and everyone on the stomp-spec mailing list for keeping the STOMP 1.1 spec moving
- Aman Gupta and contributors to eventmachine for the insights into working with non-blocking IO in Ruby