Class: RPCBench::Stomp::Client

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

Constant Summary collapse

TEMP_QNAME =
'/temp-queue/rpc-bench'

Instance Method Summary collapse

Methods inherited from Driver

#close, #send, #set_handler

Constructor Details

#initialize(opts) ⇒ Client

Returns a new instance of Client.



9
10
11
# File 'lib/rpc_bench/driver_stomp.rb', line 9

def initialize opts
  @opts = opts
end

Instance Method Details

#send_request(data, count) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rpc_bench/driver_stomp.rb', line 13

def send_request data, count
  results = []

  conn = ::Stomp::Connection.open('guest', 'guest', @opts[:host], @opts[:port])
  (1..count).each do |x|
    conn.publish(RPCBench::Stomp::QNAME, data.to_s, {
      'reply-to' => TEMP_QNAME
    })
  end
  (1..count).each do |_|
    results << conn.receive.body.slice(/[0-9]*/).to_i
  end
  conn.disconnect

  results
end