class ActiveStomp::Base
Attributes
client[RW]
config[RW]
queue[RW]
respond[RW]
Public Class Methods
new(configuration = {})
click to toggle source
# File lib/active_stomp/base.rb, line 3 def initialize(configuration = {}) self.config = configuration self.client = ::Stomp::Client.new(config[:stomp]) self.queue = config[:queue] || '/queue/stomp' self.respond = config[:respond] || 'client' end
Public Instance Methods
destroy()
click to toggle source
# File lib/active_stomp/base.rb, line 26 def destroy client.close end
start(&block)
click to toggle source
# File lib/active_stomp/base.rb, line 11 def start(&block) Signal.trap('INT') do destroy end listen(&block) client.join end
stop()
click to toggle source
# File lib/active_stomp/base.rb, line 21 def stop client.unsubscribe queue client.join end
Protected Instance Methods
listen(&block)
click to toggle source
# File lib/active_stomp/base.rb, line 32 def listen(&block) client.subscribe queue, { ack: respond } do |message| reply = block.call(message.body) if respond == 'client' if reply == :ack client.acknowledge(message) else client.nack(message) end end end end
respond=(value)
click to toggle source
param [String] value
# File lib/active_stomp/base.rb, line 50 def respond=(value) value = :auto unless ['auto', 'client'].include? value @respond = value end