Class: MQBench::STOMP

Inherits:
Client
  • Object
show all
Defined in:
lib/mqbench/stomp.rb

Constant Summary

Constants inherited from Client

Client::QNAME

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ STOMP

Returns a new instance of STOMP.



5
6
7
8
9
10
11
12
13
# File 'lib/mqbench/stomp.rb', line 5

def initialize(args)
  @port = 61613
  @user = 'guest'
  @pass = 'guest'
  
  super(args)
  
  @broker = Stomp::Connection.open(@user, @pass, @host, @port)
end

Instance Method Details

#recv_msgObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mqbench/stomp.rb', line 21

def recv_msg
  @broker.subscribe(QNAME, {:ack => 'client'})
  cnt = 0
  loop do
    @broker.receive
  
    cnt += 1
    if cnt >= @count
      break
    end
  end
end

#send_msgObject



15
16
17
18
19
# File 'lib/mqbench/stomp.rb', line 15

def send_msg
  (1..@count).each do |x|
    @broker.publish(QNAME, 'a' * @size)
  end
end