Class: ActiveStomp::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_stomp/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration = {}) ⇒ Base

Returns a new instance of Base.



3
4
5
6
7
8
9
# 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

Instance Method Details

#destroyObject



26
27
28
# File 'lib/active_stomp/base.rb', line 26

def destroy
  client.close
end

#start(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/active_stomp/base.rb', line 11

def start(&block)
  Signal.trap('INT') do
    destroy
  end

  listen(&block)

  client.join
end

#stopObject



21
22
23
24
# File 'lib/active_stomp/base.rb', line 21

def stop
  client.unsubscribe queue
  client.join
end