Class: RPCBench::Stomp::Server

Inherits:
Driver
  • Object
show all
Defined in:
lib/rpc_bench/driver_stomp.rb

Instance Method Summary collapse

Methods inherited from Driver

#close, #send, #set_handler

Constructor Details

#initialize(opts) ⇒ Server

Returns a new instance of Server.



31
32
33
# File 'lib/rpc_bench/driver_stomp.rb', line 31

def initialize opts
  @opts = opts
end

Instance Method Details

#runObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rpc_bench/driver_stomp.rb', line 35

def run
  conn = ::Stomp::Connection.open('guest', 'guest', @opts[:host], @opts[:port])

  conn.subscribe RPCBench::Stomp::QNAME
  loop do
    msg = conn.receive
    reply = @handler.callback(msg.body.to_i)
  
    conn.publish(msg.headers['reply-to'], reply.to_s)
  end
end