A suite of Celluloid actors to consume and produce to queues with Stomp protocol.
Add this line to your application's Gemfile:
gem 'stomp_actors'
And then execute:
$ bundle
Or install it yourself as:
$ gem install stomp_actors
Inherit from StompActors::Consumer
then define #queue
and #connect_opts
values, and #receive(msg)
method.
Define #subscribe_opts
to customize subscription options.
Use ack(msg)
to acknowledge message, if needed.
Example:
class MyConsumer < StompActors::Consumer
def connect_opts
# stomp gem hash login, see:
# https://github.com/stompgem/stomp#hash-login-example-usage-this-is-the-recommended-login-technique
{
hosts: [{ host: "127.0.0.1", port: 61613}]
}
end
def queue
"/queue/foo"
end
def subscribe_opts
{ ack: 'client' }
end
def receive(msg)
# do something with msg
ack(msg)
end
end
MyConsumer.new # your actor is now subscribed and will receive messages.
Inherit from StompActors::Producer
then define #queue
and #connect_opts
values.
Use emit(msg)
to send message to the defined queue.
Example:
class MyProducer < StompActors::Producer
def connect_opts
{
hosts: [{ host: "127.0.0.1", port: 61613}]
}
end
def queue
"/queue/foo"
end
end
p = MyProducer.new
p.emit("stuff") # message sent to queue
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request