mbus 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/README.mediawiki +169 -0
  3. data/Rakefile +24 -0
  4. data/bin/console +11 -0
  5. data/bin/messagebus_swarm +77 -0
  6. data/lib/messagebus.rb +62 -0
  7. data/lib/messagebus/client.rb +166 -0
  8. data/lib/messagebus/cluster_map.rb +161 -0
  9. data/lib/messagebus/connection.rb +118 -0
  10. data/lib/messagebus/consumer.rb +447 -0
  11. data/lib/messagebus/custom_errors.rb +37 -0
  12. data/lib/messagebus/dottable_hash.rb +113 -0
  13. data/lib/messagebus/error_status.rb +42 -0
  14. data/lib/messagebus/logger.rb +45 -0
  15. data/lib/messagebus/message.rb +168 -0
  16. data/lib/messagebus/messagebus_types.rb +107 -0
  17. data/lib/messagebus/producer.rb +187 -0
  18. data/lib/messagebus/swarm.rb +49 -0
  19. data/lib/messagebus/swarm/controller.rb +296 -0
  20. data/lib/messagebus/swarm/drone.rb +195 -0
  21. data/lib/messagebus/swarm/drone/logging_worker.rb +53 -0
  22. data/lib/messagebus/validations.rb +68 -0
  23. data/lib/messagebus/version.rb +36 -0
  24. data/messagebus.gemspec +29 -0
  25. data/spec/messagebus/client_spec.rb +157 -0
  26. data/spec/messagebus/cluster_map_spec.rb +178 -0
  27. data/spec/messagebus/consumer_spec.rb +338 -0
  28. data/spec/messagebus/dottable_hash_spec.rb +137 -0
  29. data/spec/messagebus/message_spec.rb +93 -0
  30. data/spec/messagebus/producer_spec.rb +147 -0
  31. data/spec/messagebus/swarm/controller_spec.rb +73 -0
  32. data/spec/messagebus/validations_spec.rb +71 -0
  33. data/spec/spec_helper.rb +10 -0
  34. data/vendor/gems/stomp.rb +23 -0
  35. data/vendor/gems/stomp/client.rb +360 -0
  36. data/vendor/gems/stomp/connection.rb +583 -0
  37. data/vendor/gems/stomp/errors.rb +39 -0
  38. data/vendor/gems/stomp/ext/hash.rb +24 -0
  39. data/vendor/gems/stomp/message.rb +68 -0
  40. metadata +138 -0
@@ -0,0 +1,178 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Messagebus::ClusterMap do
4
+ before do
5
+ @config = {
6
+ "user" => "RandySavage",
7
+ "passwd" => "snap.into.a.slim.jim",
8
+ "clusters" => ["name" => "producer-cluster", "producer_address" => "localhost:61613", "destinations" => [
9
+ "jms.queue.testQueue1", "jms.topic.testTopic1"]
10
+ ]
11
+ }
12
+
13
+ logger = mock(Logger, :info => true, :debug => true)
14
+ Messagebus::Client.stub!(:logger).and_return(logger)
15
+ end
16
+
17
+ describe "constructing a cluster map" do
18
+ before do
19
+ @producer = mock(Messagebus::Producer, :host_params => true)
20
+ Messagebus::Producer.stub!(:new).and_return(@producer)
21
+ end
22
+
23
+ it "creates a producer for each cluster configured" do
24
+ cluster = @config["clusters"].first
25
+ cluster_config = cluster.dup
26
+ host_params = cluster_config.delete("producer_address")
27
+
28
+ Messagebus::Producer.should_receive(:new).with(host_params, hash_including({
29
+ :user => "RandySavage", :passwd => "snap.into.a.slim.jim", :receipt_wait_timeout_ms => nil,
30
+ :conn_lifetime_sec => nil
31
+ }))
32
+ Messagebus::ClusterMap.new(@config)
33
+ end
34
+
35
+ it "creates a destination for each cluster destination name configured" do
36
+ expected_map = {
37
+ "jms.queue.testQueue1" => @producer,
38
+ "jms.topic.testTopic1" => @producer
39
+ }
40
+
41
+ clustermap = Messagebus::ClusterMap.new(@config)
42
+ expected_map.should == clustermap.destinations
43
+ clustermap.destinations.each do |destination, producer|
44
+
45
+ end
46
+ end
47
+
48
+ it "fails with exception if no destinations are configured" do
49
+ lambda {
50
+ @config["clusters"].first.merge!("destinations" => [])
51
+ Messagebus::ClusterMap.new(@config)
52
+ }.should raise_error(Messagebus::Client::InitializationError)
53
+
54
+ lambda {
55
+ @config["clusters"].first.merge!("destinations" => nil)
56
+ Messagebus::ClusterMap.new(@config)
57
+ }.should raise_error(Messagebus::Client::InitializationError)
58
+ end
59
+ end
60
+
61
+ describe "#start" do
62
+ before do
63
+ @producer = mock(Messagebus::Producer, :host_params => true)
64
+ Messagebus::Producer.stub!(:new).and_return(@producer)
65
+ end
66
+
67
+ it "producer start is called" do
68
+ @producer.should_receive(:start)
69
+ Messagebus::ClusterMap.new(@config).start
70
+ end
71
+ end
72
+
73
+ describe "update clusters with top level configurations" do
74
+ before do
75
+ @producer = mock(Messagebus::Producer, :host_params => true)
76
+ Messagebus::Producer.stub!(:new).and_return(@producer)
77
+
78
+ @config = {
79
+ "user" => "top-level-name",
80
+ "clusters" => ["name" => "producer-cluster", "producer_address" => "localhost:61613", "destinations" => [
81
+ "jms.queue.testQueue1", "jms.topic.testTopic1"]
82
+ ]
83
+ }
84
+ end
85
+
86
+ it "creates a producer for each cluster configured with top level name." do
87
+ cluster = @config["clusters"].first
88
+ cluster_config = cluster.dup
89
+ host_params = cluster_config.delete("producer_address")
90
+
91
+ Messagebus::Producer.should_receive(:new).with(host_params, hash_including({
92
+ :user => 'top-level-name', :passwd => nil, :receipt_wait_timeout_ms => nil,
93
+ :conn_lifetime_sec => nil
94
+ }))
95
+ Messagebus::ClusterMap.new(@config)
96
+ end
97
+
98
+ it "creates a producer for each cluster configured with cluster level name." do
99
+ @config["clusters"].first.merge!({"user" => 'cluster-level-name'})
100
+ cluster = @config["clusters"].first
101
+ cluster_config = cluster.dup
102
+ host_params = cluster_config.delete("producer_address")
103
+
104
+ Messagebus::Producer.should_receive(:new).with(host_params, hash_including({
105
+ :user => 'cluster-level-name', :passwd => nil, :receipt_wait_timeout_ms => nil,
106
+ :conn_lifetime_sec => nil
107
+ }))
108
+ Messagebus::ClusterMap.new(@config)
109
+ end
110
+ end
111
+
112
+ describe "#stop" do
113
+ before do
114
+ @producer = mock(Messagebus::Producer, :host_params => true)
115
+ Messagebus::Producer.stub!(:new).and_return(@producer)
116
+ @producer.stub!(:started?).and_return(true)
117
+ end
118
+
119
+ it "producer stop is called" do
120
+ @producer.should_receive(:stop)
121
+ Messagebus::ClusterMap.new(@config).stop
122
+ end
123
+ end
124
+
125
+ describe "#find" do
126
+ before do
127
+ @producer = mock(Messagebus::Producer, :host_params => true)
128
+ Messagebus::Producer.stub!(:new).and_return(@producer)
129
+ end
130
+
131
+ it "succeeds in finding a destination by name" do
132
+ Messagebus::ClusterMap.new(@config).find("jms.queue.testQueue1").should == @producer
133
+ end
134
+ end
135
+
136
+ describe "#update_config" do
137
+ before do
138
+ @producer = Messagebus::Producer.new(
139
+ "localhost:61613",
140
+ :user => "RandySavage",
141
+ :passwd => "snap.into.a.slim.jim"
142
+ )
143
+ Messagebus::Producer.stub!(:new).and_return(@producer)
144
+ end
145
+
146
+ it "update_cluster is called" do
147
+ clustermap = Messagebus::ClusterMap.new(@config)
148
+ cluster_config = @config["clusters"].first
149
+ cluster = @config.merge(cluster_config)
150
+ clustermap.should_receive(:update_cluster).with(cluster)
151
+ clustermap.update_config(@config)
152
+ end
153
+
154
+ it "succeeds in loading new destiantions from config" do
155
+ clustermap = Messagebus::ClusterMap.new(@config)
156
+ @config["clusters"].first["destinations"].push("jms.topic.testTopic2")
157
+ clustermap.update_config(@config)
158
+ expected_map = {
159
+ "jms.queue.testQueue1" => @producer,
160
+ "jms.topic.testTopic1" => @producer,
161
+ "jms.topic.testTopic2" => @producer
162
+ }
163
+ expected_map.should == clustermap.destinations
164
+ end
165
+
166
+
167
+ it "succeeds in creating new clusters" do
168
+ clustermap = Messagebus::ClusterMap.new(@config)
169
+ @config["clusters"].push("name" => "customer-cluster", "producer_address" => "localhost:61613", "destinations" => [
170
+ "jms.queue.testQueue1", "jms.topic.testTopic1"]
171
+ )
172
+ cluster_config = @config["clusters"][1]
173
+ cluster = @config.merge(cluster_config)
174
+ clustermap.should_receive(:create_cluster).with(cluster,true)
175
+ clustermap.update_config(@config)
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,338 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ require 'thread'
4
+ require 'net/http'
5
+
6
+ describe Messagebus::Consumer do
7
+ DYNAMIC_URL = "http://localhost:8081/jmx?command=get_attribute&args=org.hornetq%3Amodule%3DCore%2Ctype%3DServer%20ListOfBrokers"
8
+
9
+ def start_test_consumer(host_params, options = {})
10
+ consumer = Messagebus::Consumer.new(host_params, options.merge({
11
+ :destination_name => 'jms.queue.testqueue'
12
+ }))
13
+
14
+ if options[:any_host_params]
15
+ consumer.should_receive(:start_servers).at_least(1)
16
+ else
17
+ consumer.should_receive(:start_servers).with(host_params, true).at_least(1)
18
+ end
19
+
20
+ consumer
21
+ end
22
+
23
+ def test_receive_message(host_params, message, options = {})
24
+ consumer = start_test_consumer(host_params, options)
25
+ fakeClient = mock(Stomp::Client)
26
+
27
+ expected_message = options[:expected_message]
28
+
29
+ if not expected_message.nil?
30
+ fakeClient.should_receive(:credit).with(message)
31
+ end
32
+
33
+ consumer.servers_running[host_params[0]] = fakeClient
34
+ if not message.nil?
35
+ if not options[:push_message_delay]
36
+ consumer.received_messages.push({:msg => message, :host_param => host_params[0], :decoded_msg => expected_message})
37
+ else
38
+ Thread.start do
39
+ sleep options[:push_message_delay]
40
+ consumer.received_messages.push({:msg => message, :host_param => host_params[0], :decoded_msg => expected_message})
41
+ end
42
+ end
43
+ end
44
+
45
+ consumer.start
46
+
47
+ if options[:receive] == 'blocking'
48
+ received_message = consumer.receive
49
+ end
50
+
51
+ if options[:receive] == 'timeout'
52
+ received_message = consumer.receive_timeout(options[:timeout_ms] || 100)
53
+ end
54
+
55
+ if options[:receive] == 'immediate'
56
+ received_message = consumer.receive_immediate
57
+ end
58
+
59
+ if(received_message != nil && options[:ack_type] == Messagebus::ACK_TYPE_AUTO_CLIENT)
60
+ fakeClient.should_receive(:acknowledge).with(message)
61
+ end
62
+
63
+ if( options[:will_call_ack])
64
+ fakeClient.should_receive(:acknowledge).with(message)
65
+ end
66
+
67
+ if( options[:will_call_nack])
68
+ fakeClient.should_receive(:nack).with(message)
69
+ end
70
+
71
+ if( options[:will_call_keepalive])
72
+ fakeClient.should_receive(:keepalive)
73
+ end
74
+
75
+ if( options[:will_call_ack_safe])
76
+ receipt = stub(Stomp::Message)
77
+ receipt.should_receive(:command).and_return('RECEIPT')
78
+ fakeClient.should_receive(:acknowledge).with(message).and_yield(receipt)
79
+ #fakeClient.should_receive(:acknowledge).and_yield
80
+ end
81
+
82
+ received_message.class.should == expected_message.class
83
+ if received_message.class == Messagebus::Message
84
+ received_message.raw_message.should == expected_message.raw_message
85
+ else
86
+ received_message.should == expected_message
87
+ end
88
+
89
+ consumer
90
+ end
91
+
92
+ before(:each) do
93
+ @message = Messagebus::Message.create("hello world1")
94
+ @msg = Stomp::Message.new(nil)
95
+ @msg.body = @message.to_thrift_binary
96
+ @msg_id = 'id-1'
97
+ @msg_string_data1 = 'test data'
98
+ @msg_json_object = {:a=> '1', :b => {:x => '2'}}
99
+ @msg_binary_data = "\xE5\xA5\xBD"
100
+
101
+ logger = mock(Logger, :info => true, :error => true)
102
+ Messagebus::Client.stub!(:logger).and_return(logger)
103
+ end
104
+
105
+ describe ".start (class method)" do
106
+ before do
107
+ @consumer = Messagebus::Consumer.new(['localhost:61613'], :destination_name => 'jms.queue.testqueue')
108
+ @consumer.should_receive(:start_servers)
109
+ Messagebus::Consumer.stub!(:new).and_return(@consumer)
110
+ end
111
+
112
+ it "auto closes the connection when a block is given" do
113
+ Messagebus::Consumer.start(['localhost:61613']) {}
114
+ @consumer.stopped?.should be_true
115
+ end
116
+
117
+ it "makes sure it stops if the block errors out" do
118
+ proc do
119
+ Messagebus::Consumer.start(['localhost:61613']) do
120
+ raise "error123"
121
+ end
122
+ end.should raise_error("error123")
123
+ @consumer.stopped?.should be_true
124
+ end
125
+
126
+ it "doesn't auto close if a block isn't given" do
127
+ Messagebus::Consumer.start(['localhost:61613'])
128
+ @consumer.stopped?.should be_false
129
+ @consumer.started?.should be_true
130
+ end
131
+ end
132
+
133
+ describe "start" do
134
+ it "starts a server" do
135
+ consumer = start_test_consumer(['localhost:61613'])
136
+ consumer.start
137
+ consumer.stopped?.should be_false
138
+ consumer.started?.should be_true
139
+ end
140
+
141
+ it "start server attached to multiple hosts" do
142
+ consumer = start_test_consumer(['localhost:61613', 'localhost:61614'])
143
+ consumer.start
144
+ end
145
+ end
146
+
147
+ context "connection failure" do
148
+ it "closes connections when only some start" do
149
+ consumer = Messagebus::Consumer.new(['host1:1', 'host2:2'], :destination_name => 'jms.queue.testqueue')
150
+ lambda do
151
+ good_client = stub.as_null_object
152
+ good_client.should_receive(:close)
153
+
154
+ Stomp::Client.should_receive(:new).and_return(good_client)
155
+ Stomp::Client.should_receive(:new).and_raise("2nd client blows up")
156
+ consumer.start
157
+ end.should raise_error("2nd client blows up")
158
+ end
159
+
160
+ it "raises an exception when we fail to connect" do
161
+ consumer = Messagebus::Consumer.new(['non_existant_host:1111'], :destination_name => 'jms.queue.testqueue')
162
+ lambda do
163
+ consumer.start
164
+ end.should raise_error
165
+ end
166
+ end
167
+
168
+ it "check refresh timer task" do
169
+ consumer = start_test_consumer(['localhost:61613', 'localhost:61614'], :conn_lifetime_sec => 0.100)
170
+ consumer.should_receive(:refresh_servers).at_least(1)
171
+ consumer.start
172
+ sleep(0.500)
173
+ end
174
+
175
+ it "check refresh timer task with dynamic fetch url return nil." do
176
+ consumer = start_test_consumer(['localhost:61613', 'localhost:61614'], :conn_lifetime_sec => 0.100,
177
+ :enable_dynamic_serverlist_fetch => 'true', :dynamic_serverlist_fetch_url_override => 'test', :any_host_params=>true)
178
+ consumer.should_receive(:fetch_serverlist).at_least(1).and_return(nil)
179
+ consumer.start
180
+ sleep(0.200)
181
+ end
182
+
183
+ it "check get dynamic fetch url host param String." do
184
+ consumer = start_test_consumer(['localhost:61613', 'localhost:61614'], :conn_lifetime_sec => 0.100)
185
+ consumer.start
186
+
187
+ DYNAMIC_URL.should == consumer.get_dynamic_fetch_url('localhost:61613')
188
+ end
189
+
190
+ it "check get dynamic fetch url host param array." do
191
+ consumer = start_test_consumer(['localhost:61613', 'localhost:61614'], :conn_lifetime_sec => 0.100)
192
+ consumer.start
193
+
194
+ DYNAMIC_URL.should == consumer.get_dynamic_fetch_url(['localhost:61613'])
195
+ end
196
+
197
+ it "check fetch_serverlist url success." do
198
+ consumer = start_test_consumer(['localhost:61613', 'localhost:61614'], :enable_dynamic_serverlist_fetch => 'true', :dynamic_serverlist_fetch_url_override => 'test')
199
+ consumer.should_receive(:fetch_uri).with("test").at_least(1).and_return('localhost:61612, localhost:61614')
200
+ consumer.should_receive(:start_servers).with(['localhost:61612', 'localhost:61614']);
201
+ consumer.start
202
+ consumer.fetch_serverlist.should =~ ['localhost:61612', 'localhost:61614']
203
+ end
204
+
205
+ it "check fetch_serverlist url fail." do
206
+ consumer = start_test_consumer(['localhost:61613', 'localhost:61614'], :enable_dynamic_serverlist_fetch => 'true', :dynamic_serverlist_fetch_url_override => 'test')
207
+ consumer.should_receive(:fetch_uri).with("test").at_least(1).and_return('<fail="localhostocalhost:61614">')
208
+
209
+ consumer.start
210
+ consumer.fetch_serverlist.should == nil
211
+ end
212
+
213
+ it "check refresh timer task with dynamic fetch url with no change." do
214
+ consumer = start_test_consumer(['localhost:61613', 'localhost:61614'], :conn_lifetime_sec => 0.100,
215
+ :enable_dynamic_serverlist_fetch => 'true', :dynamic_serverlist_fetch_url_override => 'test')
216
+ consumer.should_receive(:fetch_serverlist).at_least(1).and_return(['localhost:61613', 'localhost:61614'])
217
+ consumer.should_receive(:stop_servers) do |array|
218
+ array.should =~ ['localhost:61613', 'localhost:61614']
219
+ end.at_least(1)
220
+
221
+ consumer.servers_running = {'localhost:61613' => 'test', 'localhost:61614' => 'test', }
222
+ consumer.start
223
+
224
+ sleep(0.150)
225
+ consumer.stop
226
+ end
227
+
228
+ it "check refresh timer task with dynamic fetch url return with added servers." do
229
+ consumer = start_test_consumer(['localhost:61613'], :conn_lifetime_sec => 0.100, :enable_dynamic_serverlist_fetch => 'true', :dynamic_serverlist_fetch_url_override => 'test')
230
+ consumer.should_receive(:fetch_serverlist).at_least(1).and_return(['localhost:61613', 'localhost:61614'])
231
+ consumer.should_receive(:start_servers).with(['localhost:61614']).at_least(1)
232
+
233
+ consumer.servers_running = {'localhost:61613' => 'test'}
234
+ consumer.start
235
+
236
+ sleep(0.150)
237
+ consumer.stop
238
+ end
239
+
240
+ # TODO (bbansal): Disabling dynamic server delete for now, seems like an overkill.
241
+ # There are chances where any user error can be disastorous.
242
+ # it "check refresh timer task with dynamic fetch url return with deleted servers." do
243
+ # consumer = start_test_consumer(['localhost:61613', 'localhost:61614'], :conn_lifetime_sec => 0.100, :enable_dynamic_serverlist_fetch => 'true', :dynamic_serverlist_fetch_url_override => 'test')
244
+ # consumer.should_receive(:fetch_serverlist).at_least(1).and_return(['localhost:61613'])
245
+ # consumer.should_receive(:stop_servers).with(['localhost:61613']).at_least(1)
246
+ # consumer.should_receive(:start_servers).with(['localhost:61613']).at_least(1)
247
+ # consumer.should_receive(:stop_servers).with(['localhost:61614'])
248
+ # consumer.should_receive(:stop_servers).with(['localhost:61613', 'localhost:61614']).at_least(1)
249
+ #
250
+ # consumer.servers_running = {'localhost:61613' => 'test', 'localhost:61614' => 'test'}
251
+ # consumer.start
252
+ #
253
+ # sleep(0.150)
254
+ # consumer.stop
255
+ # end
256
+
257
+ it "check delete subscriptions." do
258
+ consumer = start_test_consumer(['localhost:61613', 'localhost:61614'])
259
+ fakeClient1 = mock(Stomp::Client)
260
+ fakeClient2 = mock(Stomp::Client)
261
+
262
+ fakeClient1.should_receive(:unsubscribe).with('jms.queue.testqueue')
263
+ fakeClient2.should_receive(:unsubscribe).with('jms.queue.testqueue')
264
+
265
+ consumer.servers_running = {'localhost:61613' => fakeClient1, 'localhost:61614' => fakeClient2}
266
+ consumer.should_receive(:refresh_servers);
267
+ consumer.start
268
+ consumer.delete_subscription
269
+ end
270
+
271
+ it "check consumer receive blocking message available." do
272
+ test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :receive => 'blocking', :expected_message => @message)
273
+ end
274
+
275
+ it "check consumer receive blocking parallel thread." do
276
+ test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :receive => 'blocking', :push_message_delay => 0.050,
277
+ :expected_message => @message)
278
+ end
279
+
280
+ it "check consumer receive immediate success." do
281
+ test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :receive => 'immediate', :expected_message => @message)
282
+ end
283
+
284
+ it "check consumer receive immediate fail." do
285
+ test_receive_message(['localhost:61613', 'localhost:61614'], nil, :receive => 'immediate', :expected_message => nil)
286
+ end
287
+
288
+ it "check consumer receive immediate fail with delayed push message" do
289
+ test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :receive => 'immediate',
290
+ :push_message_delay => 0.050, :expected_message => nil)
291
+ end
292
+
293
+ it "check consumer receive immediate with client ack" do
294
+ consumer = test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :ack_type => Messagebus::ACK_TYPE_CLIENT, :receive => 'immediate',
295
+ :expected_message => @message, :will_call_ack => true)
296
+
297
+ consumer.ack
298
+ end
299
+
300
+ it "check consumer sends ack with block in safe mode" do
301
+ consumer = test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :ack_type => Messagebus::ACK_TYPE_CLIENT, :receive => 'immediate',
302
+ :expected_message => @message, :will_call_ack_safe => true)
303
+ consumer.ack true
304
+ end
305
+
306
+ it "check consumer receive immediate with client nack" do
307
+ consumer = test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :ack_type => Messagebus::ACK_TYPE_CLIENT, :receive => 'immediate',
308
+ :expected_message => @message, :will_call_nack => true)
309
+
310
+ consumer.nack
311
+ end
312
+
313
+ it "check consumer keepalive" do
314
+ consumer = test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :ack_type => Messagebus::ACK_TYPE_CLIENT, :receive => 'immediate',
315
+ :expected_message => @message, :will_call_keepalive => true)
316
+
317
+ consumer.keepalive
318
+ end
319
+
320
+ it "check consumer receive timeout fail." do
321
+ expect {
322
+ test_receive_message(['localhost:61613', 'localhost:61614'], nil, :receive => 'timeout', :timeout_ms => 100, :push_message_delay => 0.500,
323
+ :expected_message => nil)
324
+ }.to raise_error(Messagebus::MessageReceiveTimeout, /receive timeout/)
325
+
326
+ sleep(0.200)
327
+ end
328
+
329
+ it "check consumer receive timeout success." do
330
+ test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :receive => 'timeout', :timeout_ms => 100,
331
+ :push_message_delay => 0.050, :expected_message => @message)
332
+ end
333
+
334
+ it "check consumer receive string message success." do
335
+ test_receive_message(['localhost:61613', 'localhost:61614'], @msg, :receive => 'timeout', :timeout_ms => 100,
336
+ :push_message_delay => 0.050, :expected_message => @message)
337
+ end
338
+ end