stomp 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +46 -3
- data/examples/artemis/artlogger.rb +41 -0
- data/examples/artemis/cliwaiter_not_reliable.rb +66 -0
- data/examples/artemis/cliwaiter_reliable.rb +61 -0
- data/examples/contrib.sh +2 -2
- data/examples/examplogger.rb +5 -3
- data/examples/ssl_uc1.rb +4 -2
- data/lib/client/utils.rb +10 -7
- data/lib/connection/heartbeats.rb +13 -11
- data/lib/connection/netio.rb +47 -14
- data/lib/connection/utils.rb +15 -5
- data/lib/stomp/client.rb +13 -6
- data/lib/stomp/connection.rb +10 -6
- data/lib/stomp/constants.rb +6 -4
- data/lib/stomp/errors.rb +25 -2
- data/lib/stomp/version.rb +4 -4
- data/spec/client_spec.rb +33 -18
- data/spec/spec_helper.rb +1 -0
- data/stomp.gemspec +21 -17
- data/test/MultiBrokerUnitTestExample.sh +65 -0
- data/test/test_anonymous.rb +29 -47
- data/test/test_client.rb +131 -131
- data/test/test_connection.rb +49 -51
- data/test/test_connection1p.rb +45 -76
- data/test/test_helper.rb +15 -2
- data/test/test_message.rb +18 -35
- data/test/test_ssl.rb +4 -10
- data/test/unitst.sh +3 -2
- metadata +7 -3
data/spec/spec_helper.rb
CHANGED
data/stomp.gemspec
CHANGED
@@ -2,19 +2,19 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: stomp 1.4.
|
5
|
+
# stub: stomp 1.4.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
|
-
s.name = "stomp"
|
9
|
-
s.version = "1.4.
|
8
|
+
s.name = "stomp".freeze
|
9
|
+
s.version = "1.4.4"
|
10
10
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["Brian McCallister", "Marius Mathiesen", "Thiago Morello", "Guy M. Allard"]
|
14
|
-
s.date = "
|
15
|
-
s.description = "Ruby client for the Stomp messaging protocol. Note that this gem is no longer supported on rubyforge."
|
16
|
-
s.email = ["brianm@apache.org", "marius@stones.com", "morellon@gmail.com", "allard.guy.m@gmail.com"]
|
17
|
-
s.executables = ["catstomp", "stompcat"]
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Brian McCallister".freeze, "Marius Mathiesen".freeze, "Thiago Morello".freeze, "Guy M. Allard".freeze]
|
14
|
+
s.date = "2017-06-11"
|
15
|
+
s.description = "Ruby client for the Stomp messaging protocol. Note that this gem is no longer supported on rubyforge.".freeze
|
16
|
+
s.email = ["brianm@apache.org".freeze, "marius@stones.com".freeze, "morellon@gmail.com".freeze, "allard.guy.m@gmail.com".freeze]
|
17
|
+
s.executables = ["catstomp".freeze, "stompcat".freeze]
|
18
18
|
s.extra_rdoc_files = [
|
19
19
|
"LICENSE",
|
20
20
|
"README.md"
|
@@ -36,6 +36,9 @@ Gem::Specification.new do |s|
|
|
36
36
|
"bin/catstomp",
|
37
37
|
"bin/stompcat",
|
38
38
|
"examples/amqdurasub.rb",
|
39
|
+
"examples/artemis/artlogger.rb",
|
40
|
+
"examples/artemis/cliwaiter_not_reliable.rb",
|
41
|
+
"examples/artemis/cliwaiter_reliable.rb",
|
39
42
|
"examples/client11_ex1.rb",
|
40
43
|
"examples/client11_putget1.rb",
|
41
44
|
"examples/conn11_ex1.rb",
|
@@ -96,6 +99,7 @@ Gem::Specification.new do |s|
|
|
96
99
|
"spec/spec_helper.rb",
|
97
100
|
"stomp.gemspec",
|
98
101
|
"test/.gitignore",
|
102
|
+
"test/MultiBrokerUnitTestExample.sh",
|
99
103
|
"test/funcs.sh",
|
100
104
|
"test/test_anonymous.rb",
|
101
105
|
"test/test_client.rb",
|
@@ -109,21 +113,21 @@ Gem::Specification.new do |s|
|
|
109
113
|
"test/tlogger.rb",
|
110
114
|
"test/unitst.sh"
|
111
115
|
]
|
112
|
-
s.homepage = "https://github.com/stompgem/stomp"
|
113
|
-
s.licenses = ["Apache-2.0"]
|
114
|
-
s.rubygems_version = "2.
|
115
|
-
s.summary = "Ruby client for the Stomp messaging protocol"
|
116
|
+
s.homepage = "https://github.com/stompgem/stomp".freeze
|
117
|
+
s.licenses = ["Apache-2.0".freeze]
|
118
|
+
s.rubygems_version = "2.6.11".freeze
|
119
|
+
s.summary = "Ruby client for the Stomp messaging protocol".freeze
|
116
120
|
|
117
121
|
if s.respond_to? :specification_version then
|
118
122
|
s.specification_version = 4
|
119
123
|
|
120
124
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
121
|
-
s.add_development_dependency(%q<rspec
|
125
|
+
s.add_development_dependency(%q<rspec>.freeze, [">= 2.14.1", "~> 2.14"])
|
122
126
|
else
|
123
|
-
s.add_dependency(%q<rspec
|
127
|
+
s.add_dependency(%q<rspec>.freeze, [">= 2.14.1", "~> 2.14"])
|
124
128
|
end
|
125
129
|
else
|
126
|
-
s.add_dependency(%q<rspec
|
130
|
+
s.add_dependency(%q<rspec>.freeze, [">= 2.14.1", "~> 2.14"])
|
127
131
|
end
|
128
132
|
end
|
129
133
|
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
set -x
|
4
|
+
#
|
5
|
+
# An example of running unit tests against multiple message brokers.
|
6
|
+
#
|
7
|
+
pref="STOMP_PORT=61613 rake test --trace"
|
8
|
+
echo =============== AMQ Stomp 1.0 ===============
|
9
|
+
eval $pref
|
10
|
+
|
11
|
+
pref="STOMP_PORT=61613 STOMP_TEST11p=1.1 STOMP_AMQ11=y STOMP_NOWILD=y rake test --trace"
|
12
|
+
echo =============== AMQ Stomp 1.1 ===============
|
13
|
+
eval $pref
|
14
|
+
|
15
|
+
pref="STOMP_PORT=61613 STOMP_TEST11p=1.2 STOMP_AMQ11=y STOMP_NOWILD=y rake test --trace"
|
16
|
+
echo =============== AMQ Stomp 1.2 ===============
|
17
|
+
eval $pref
|
18
|
+
|
19
|
+
pref="STOMP_TESTSSL=y STOMP_PORT=62613 STOMP_SSLPORT=62614 STOMP_DOTQUEUE=y STOMP_NOWILD=y rake test --trace"
|
20
|
+
echo =============== Apollo Stomp 1.0 ===============
|
21
|
+
eval $pref
|
22
|
+
|
23
|
+
pref="STOMP_TESTSSL=y STOMP_PORT=62613 STOMP_SSLPORT=62614 STOMP_DOTQUEUE=y STOMP_TEST11p=1.1 STOMP_NOWILD=y STOMP_APOLLO=y rake test --trace"
|
24
|
+
echo =============== Apollo Stomp 1.1 ===============
|
25
|
+
eval $pref
|
26
|
+
|
27
|
+
pref="STOMP_TESTSSL=y STOMP_PORT=62613 STOMP_SSLPORT=62614 STOMP_DOTQUEUE=y STOMP_TEST11p=1.2 STOMP_NOWILD=y STOMP_APOLLO=y rake test --trace"
|
28
|
+
echo =============== Apollo Stomp 1.2 ===============
|
29
|
+
eval $pref
|
30
|
+
|
31
|
+
pref="STOMP_TESTSSL=y STOMP_PORT=62613 STOMP_SSLPORT=62614 STOMP_DOTQUEUE=y STOMP_TEST11p=1.2 STOMP_NOWILD=y STOMP_CRLF=y STOMP_APOLLO=y rake test --trace"
|
32
|
+
echo =============== Apollo Stomp 1.2 - CRLF=y ===============
|
33
|
+
eval $pref
|
34
|
+
|
35
|
+
pref="STOMP_TESTSSL=y STOMP_PORT=62613 STOMP_SSLPORT=62614 STOMP_DOTQUEUE=y STOMP_TEST11p=1.2 STOMP_NOWILD=y STOMP_CONN=y STOMP_APOLLO=y rake test --trace"
|
36
|
+
echo =============== Apollo Stomp 1.2 - CONN=y ===============
|
37
|
+
eval $pref
|
38
|
+
|
39
|
+
pref="STOMP_RABBIT=y STOMP_PORT=41613 STOMP_DOTQUEUE=y STOMP_NOWILD=y rake test --trace"
|
40
|
+
echo =============== RabbitMQ Stomp 1.0 ===============
|
41
|
+
eval $pref
|
42
|
+
|
43
|
+
pref="STOMP_RABBIT=y STOMP_PORT=41613 STOMP_DOTQUEUE=y STOMP_NOWILD=y STOMP_TEST11p=1.1 rake test --trace"
|
44
|
+
echo =============== RabbitMQ Stomp 1.1 ===============
|
45
|
+
eval $pref
|
46
|
+
|
47
|
+
pref="STOMP_RABBIT=y STOMP_PORT=41613 STOMP_DOTQUEUE=y STOMP_NOWILD=y STOMP_TEST11p=1.2 rake test --trace"
|
48
|
+
echo =============== RabbitMQ Stomp 1.2 ===============
|
49
|
+
eval $pref
|
50
|
+
|
51
|
+
pref="STOMP_ARTEMIS=y STOMP_PORT=31613 STOMP_NOWILD=y rake test --trace"
|
52
|
+
echo =============== Artemis Stomp 1.0 ===============
|
53
|
+
eval $pref
|
54
|
+
|
55
|
+
pref="STOMP_ARTEMIS=y STOMP_PORT=31613 STOMP_NOWILD=y STOMP_TEST11p=1.1 rake test --trace"
|
56
|
+
echo =============== Artemis Stomp 1.1 ===============
|
57
|
+
eval $pref
|
58
|
+
|
59
|
+
pref="STOMP_ARTEMIS=y STOMP_PORT=31613 STOMP_NOWILD=y STOMP_TEST11p=1.2 rake test --trace"
|
60
|
+
echo =============== Artemis Stomp 1.2 ===============
|
61
|
+
eval $pref
|
62
|
+
|
63
|
+
set +x
|
64
|
+
exit 0
|
65
|
+
|
data/test/test_anonymous.rb
CHANGED
@@ -33,7 +33,9 @@ class TestAnonymous < Test::Unit::TestCase
|
|
33
33
|
|
34
34
|
# Test asynchronous polling.
|
35
35
|
def test_poll_async
|
36
|
-
|
36
|
+
sq = ENV['STOMP_ARTEMIS'] ? "jms.queue.queue.do.not.put.messages.on.this.queue" :
|
37
|
+
"/queue/do.not.put.messages.on.this.queue"
|
38
|
+
@conn.subscribe(sq, :id => "a.no.messages.queue")
|
37
39
|
# If the test 'hangs' here, Connection#poll is broken.
|
38
40
|
m = @conn.poll
|
39
41
|
assert m.nil?
|
@@ -74,11 +76,9 @@ class TestAnonymous < Test::Unit::TestCase
|
|
74
76
|
# Test asking for a receipt on disconnect.
|
75
77
|
def test_disconnect_receipt
|
76
78
|
@conn.disconnect :receipt => "abc123"
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
"abc123", "receipt sent and received should match")
|
81
|
-
}
|
79
|
+
assert_not_nil(@conn.disconnect_receipt, "should have a receipt")
|
80
|
+
assert_equal(@conn.disconnect_receipt.headers['receipt-id'],
|
81
|
+
"abc123", "receipt sent and received should match")
|
82
82
|
end
|
83
83
|
|
84
84
|
# Test ACKs for Stomp 1.0
|
@@ -91,11 +91,9 @@ class TestAnonymous < Test::Unit::TestCase
|
|
91
91
|
@conn.subscribe queue, :ack => :client
|
92
92
|
@conn.publish queue, "test_stomp#test_client_ack_with_symbol_10"
|
93
93
|
msg = @conn.receive
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
@conn.ack msg.headers['message-id']
|
98
|
-
}
|
94
|
+
# ACK has one required header, message-id, which must contain a value
|
95
|
+
# matching the message-id for the MESSAGE being acknowledged.
|
96
|
+
@conn.ack msg.headers['message-id']
|
99
97
|
checkEmsg(@conn)
|
100
98
|
end
|
101
99
|
|
@@ -110,13 +108,11 @@ class TestAnonymous < Test::Unit::TestCase
|
|
110
108
|
@conn.subscribe queue, :ack => :client, :id => sid
|
111
109
|
@conn.publish queue, "test_stomp#test_client_ack_with_symbol_11"
|
112
110
|
msg = @conn.receive
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
@conn.ack msg.headers['message-id'], :subscription => msg.headers['subscription']
|
119
|
-
}
|
111
|
+
# ACK has two REQUIRED headers: message-id, which MUST contain a value
|
112
|
+
# matching the message-id for the MESSAGE being acknowledged and
|
113
|
+
# subscription, which MUST be set to match the value of the subscription's
|
114
|
+
# id header.
|
115
|
+
@conn.ack msg.headers['message-id'], :subscription => msg.headers['subscription']
|
120
116
|
checkEmsg(@conn)
|
121
117
|
end
|
122
118
|
|
@@ -131,11 +127,9 @@ class TestAnonymous < Test::Unit::TestCase
|
|
131
127
|
@conn.subscribe queue, :ack => :client, :id => sid
|
132
128
|
@conn.publish queue, "test_stomp#test_client_ack_with_symbol_11"
|
133
129
|
msg = @conn.receive
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
@conn.ack msg.headers['ack']
|
138
|
-
}
|
130
|
+
# The ACK frame MUST include an id header matching the ack header
|
131
|
+
# of the MESSAGE being acknowledged.
|
132
|
+
@conn.ack msg.headers['ack']
|
139
133
|
checkEmsg(@conn)
|
140
134
|
end
|
141
135
|
|
@@ -387,9 +381,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
387
381
|
# Test using a nil body.
|
388
382
|
def test_nil_body
|
389
383
|
dest = make_destination
|
390
|
-
|
391
|
-
@conn.publish dest, nil
|
392
|
-
}
|
384
|
+
@conn.publish dest, nil
|
393
385
|
conn_subscribe dest
|
394
386
|
msg = @conn.receive
|
395
387
|
assert_equal "", msg.body
|
@@ -412,7 +404,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
412
404
|
msg = @conn.receive
|
413
405
|
assert_equal "txn message", msg.body
|
414
406
|
checkEmsg(@conn)
|
415
|
-
end
|
407
|
+
end unless ENV['STOMP_ARTEMIS'] # See Artemis docs for 1.3, page 222
|
416
408
|
|
417
409
|
# Test duplicate subscriptions.
|
418
410
|
def test_duplicate_subscription
|
@@ -431,9 +423,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
431
423
|
def test_nil_connparms
|
432
424
|
@conn.disconnect
|
433
425
|
#
|
434
|
-
|
435
|
-
@conn = Stomp::Connection.open(nil, nil, host, port, false, 5, nil)
|
436
|
-
end
|
426
|
+
@conn = Stomp::Connection.open(nil, nil, host, port, false, 5, nil)
|
437
427
|
checkEmsg(@conn)
|
438
428
|
end
|
439
429
|
|
@@ -454,17 +444,13 @@ class TestAnonymous < Test::Unit::TestCase
|
|
454
444
|
assert_equal smsg, msg.body
|
455
445
|
case @conn.protocol
|
456
446
|
when Stomp::SPL_12
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
@conn.unsubscribe dest, :id => sid
|
461
|
-
}
|
447
|
+
@conn.nack msg.headers["ack"]
|
448
|
+
sleep 0.05 # Give racy brokers a chance to handle the last nack before unsubscribe
|
449
|
+
@conn.unsubscribe dest, :id => sid
|
462
450
|
else # Stomp::SPL_11
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
@conn.unsubscribe dest, :id => sid
|
467
|
-
}
|
451
|
+
@conn.nack msg.headers["message-id"], :subscription => sid
|
452
|
+
sleep 0.05 # Give racy brokers a chance to handle the last nack before unsubscribe
|
453
|
+
@conn.unsubscribe dest, :id => sid
|
468
454
|
end
|
469
455
|
|
470
456
|
# phase 2
|
@@ -476,7 +462,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
476
462
|
assert_equal smsg, msg2.body
|
477
463
|
checkEmsg(@conn)
|
478
464
|
end
|
479
|
-
end unless ENV['STOMP_AMQ11']
|
465
|
+
end unless (ENV['STOMP_AMQ11'] || ENV['STOMP_ARTEMIS'])
|
480
466
|
|
481
467
|
# Test to illustrate Issue #44. Prior to a fix for #44, these tests would
|
482
468
|
# fail only when connecting to a pure STOMP 1.0 server that does not
|
@@ -492,9 +478,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
492
478
|
:reliable => false,
|
493
479
|
}
|
494
480
|
c = nil
|
495
|
-
|
496
|
-
c = Stomp::Connection.new(hash)
|
497
|
-
}
|
481
|
+
c = Stomp::Connection.new(hash)
|
498
482
|
c.disconnect if c
|
499
483
|
#
|
500
484
|
hash = { :hosts => [
|
@@ -504,9 +488,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
504
488
|
:reliable => false,
|
505
489
|
}
|
506
490
|
c = nil
|
507
|
-
|
508
|
-
c = Stomp::Connection.new(hash)
|
509
|
-
}
|
491
|
+
c = Stomp::Connection.new(hash)
|
510
492
|
c.disconnect if c
|
511
493
|
end
|
512
494
|
|
data/test/test_client.rb
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
=end
|
15
15
|
class TestClient < Test::Unit::TestCase
|
16
16
|
include TestBase
|
17
|
-
|
17
|
+
|
18
18
|
def setup
|
19
19
|
@client = get_client()
|
20
20
|
# Multi_thread test data
|
@@ -102,11 +102,9 @@ class TestClient < Test::Unit::TestCase
|
|
102
102
|
# Test requesting a receipt on disconnect.
|
103
103
|
def test_disconnect_receipt
|
104
104
|
@client.close :receipt => "xyz789"
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
"xyz789", "receipt sent and received should match")
|
109
|
-
}
|
105
|
+
assert_not_nil(@client.disconnect_receipt, "should have a receipt")
|
106
|
+
assert_equal(@client.disconnect_receipt.headers['receipt-id'],
|
107
|
+
"xyz789", "receipt sent and received should match")
|
110
108
|
end
|
111
109
|
|
112
110
|
# Test publish and immediate subscribe.
|
@@ -122,7 +120,7 @@ class TestClient < Test::Unit::TestCase
|
|
122
120
|
|
123
121
|
# Test that Client subscribe requires a block.
|
124
122
|
def test_subscribe_requires_block
|
125
|
-
assert_raise(
|
123
|
+
assert_raise(Stomp::Error::NoListenerGiven) do
|
126
124
|
@client.subscribe make_destination
|
127
125
|
end
|
128
126
|
checkEmsg(@client)
|
@@ -179,21 +177,19 @@ class TestClient < Test::Unit::TestCase
|
|
179
177
|
end
|
180
178
|
sleep 0.01 until message
|
181
179
|
assert_equal data, message.body
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
@client.abort 'tx1' # now abort
|
196
|
-
}
|
180
|
+
case @client.protocol()
|
181
|
+
when Stomp::SPL_10
|
182
|
+
@client.acknowledge message, :transaction => 'tx1'
|
183
|
+
checkEmsg(@client)
|
184
|
+
when Stomp::SPL_11
|
185
|
+
@client.acknowledge message, :transaction => 'tx1', :subscription => message.headers['subscription']
|
186
|
+
checkEmsg(@client)
|
187
|
+
else # 1.2+
|
188
|
+
@client.acknowledge message, :transaction => 'tx1', :id => message.headers['ack']
|
189
|
+
checkEmsg(@client)
|
190
|
+
end
|
191
|
+
message = nil # reset
|
192
|
+
@client.abort 'tx1' # now abort
|
197
193
|
checkEmsg(@client)
|
198
194
|
# lets recreate the connection
|
199
195
|
@client.close
|
@@ -201,34 +197,30 @@ class TestClient < Test::Unit::TestCase
|
|
201
197
|
sid = nil
|
202
198
|
message2 = nil
|
203
199
|
@client.begin 'tx2'
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
end
|
211
|
-
}
|
200
|
+
if @client.protocol() == Stomp::SPL_10
|
201
|
+
@client.subscribe(q, :ack => 'client') {|m| message2 = m}
|
202
|
+
else # 1.1 and 1.2 are the same for this
|
203
|
+
sid = @client.uuid()
|
204
|
+
@client.subscribe(q, :ack => 'client', :id => sid) {|m| message2 = m}
|
205
|
+
end
|
212
206
|
sleep 0.01 until message2
|
213
207
|
assert_not_nil message
|
214
208
|
assert_equal data, message2.body
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
@client.commit 'tx2'
|
228
|
-
}
|
209
|
+
case @client.protocol()
|
210
|
+
when Stomp::SPL_10
|
211
|
+
@client.acknowledge message2, :transaction => 'tx2'
|
212
|
+
checkEmsg(@client)
|
213
|
+
when Stomp::SPL_11
|
214
|
+
@client.acknowledge message2, :transaction => 'tx2', :subscription => message2.headers['subscription']
|
215
|
+
checkEmsg(@client)
|
216
|
+
else # 1.2+
|
217
|
+
@client.acknowledge message2, :transaction => 'tx2', :id => message2.headers['ack']
|
218
|
+
checkEmsg(@client)
|
219
|
+
end
|
220
|
+
@client.commit 'tx2'
|
229
221
|
checkEmsg(@client)
|
230
222
|
@client.close
|
231
|
-
end
|
223
|
+
end unless ENV['STOMP_ARTEMIS'] # See Artemis docs for 1.3, page 222
|
232
224
|
|
233
225
|
# Test transaction publish and abort, receive with new client.
|
234
226
|
# New client uses ack => auto.
|
@@ -250,21 +242,19 @@ class TestClient < Test::Unit::TestCase
|
|
250
242
|
end
|
251
243
|
sleep 0.01 until message
|
252
244
|
assert_equal data, message.body
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
@client.abort 'tx1' # now abort
|
267
|
-
}
|
245
|
+
case @client.protocol()
|
246
|
+
when Stomp::SPL_10
|
247
|
+
@client.acknowledge message, :transaction => 'tx1'
|
248
|
+
checkEmsg(@client)
|
249
|
+
when Stomp::SPL_11
|
250
|
+
@client.acknowledge message, :transaction => 'tx1', :subscription => message.headers['subscription']
|
251
|
+
checkEmsg(@client)
|
252
|
+
else # 1.2+
|
253
|
+
@client.acknowledge message, :transaction => 'tx1', :id => message.headers['ack']
|
254
|
+
checkEmsg(@client)
|
255
|
+
end
|
256
|
+
message = nil # reset
|
257
|
+
@client.abort 'tx1' # now abort
|
268
258
|
checkEmsg(@client)
|
269
259
|
# lets recreate the connection
|
270
260
|
@client.close
|
@@ -273,27 +263,25 @@ class TestClient < Test::Unit::TestCase
|
|
273
263
|
sid = nil
|
274
264
|
message2 = nil
|
275
265
|
@client.begin 'tx2'
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
end
|
283
|
-
}
|
266
|
+
if @client.protocol() == Stomp::SPL_10
|
267
|
+
@client.subscribe(q, :ack => 'auto') {|m| message2 = m}
|
268
|
+
else # 1.1 and 1.2 are the same for this
|
269
|
+
sid = @client.uuid()
|
270
|
+
@client.subscribe(q, :ack => 'auto', :id => sid) {|m| message2 = m}
|
271
|
+
end
|
284
272
|
sleep 0.01 until message2
|
285
273
|
assert_not_nil message2
|
286
274
|
assert_equal data, message2.body
|
287
275
|
@client.commit 'tx2'
|
288
276
|
checkEmsg(@client)
|
289
277
|
@client.close
|
290
|
-
end
|
278
|
+
end unless ENV['STOMP_ARTEMIS'] # See Artemis docs for 1.3, page 222
|
291
279
|
|
292
280
|
# Test that subscription destinations must be unique for a Client.
|
293
281
|
def test_raise_on_multiple_subscriptions_to_same_make_destination
|
294
282
|
subscribe_dest = make_destination
|
295
283
|
@client.subscribe(subscribe_dest) {|m| nil }
|
296
|
-
assert_raise(
|
284
|
+
assert_raise(Stomp::Error::DuplicateSubscription) do
|
297
285
|
@client.subscribe(subscribe_dest) {|m| nil }
|
298
286
|
end
|
299
287
|
checkEmsg(@client)
|
@@ -303,7 +291,7 @@ class TestClient < Test::Unit::TestCase
|
|
303
291
|
def test_raise_on_multiple_subscriptions_to_same_id
|
304
292
|
subscribe_dest = make_destination
|
305
293
|
@client.subscribe(subscribe_dest, {'id' => 'myid'}) {|m| nil }
|
306
|
-
assert_raise(
|
294
|
+
assert_raise(Stomp::Error::DuplicateSubscription) do
|
307
295
|
@client.subscribe(subscribe_dest, {'id' => 'myid'}) {|m| nil }
|
308
296
|
end
|
309
297
|
checkEmsg(@client)
|
@@ -313,7 +301,7 @@ class TestClient < Test::Unit::TestCase
|
|
313
301
|
def test_raise_on_multiple_subscriptions_to_same_id_mixed
|
314
302
|
subscribe_dest = make_destination
|
315
303
|
@client.subscribe(subscribe_dest, {'id' => 'myid'}) {|m| nil }
|
316
|
-
assert_raise(
|
304
|
+
assert_raise(Stomp::Error::DuplicateSubscription) do
|
317
305
|
@client.subscribe(subscribe_dest, {:id => 'myid'}) {|m| nil }
|
318
306
|
end
|
319
307
|
checkEmsg(@client)
|
@@ -341,7 +329,7 @@ class TestClient < Test::Unit::TestCase
|
|
341
329
|
assert_equal send_message, message.body
|
342
330
|
end
|
343
331
|
results = [queue1, queue2].collect do |queue|
|
344
|
-
messages.any? do |message|
|
332
|
+
messages.any? do |message|
|
345
333
|
message_source = message.headers['destination']
|
346
334
|
message_source == queue
|
347
335
|
end
|
@@ -376,7 +364,7 @@ class TestClient < Test::Unit::TestCase
|
|
376
364
|
end
|
377
365
|
# make sure that the messages received came from the expected queues
|
378
366
|
results = [queue1, queue2, queue3].collect do |queue|
|
379
|
-
messages.any? do |message|
|
367
|
+
messages.any? do |message|
|
380
368
|
message_source = message.headers['destination']
|
381
369
|
message_source == queue
|
382
370
|
end
|
@@ -421,21 +409,19 @@ class TestClient < Test::Unit::TestCase
|
|
421
409
|
sleep 0.1 while message.nil?
|
422
410
|
assert_not_nil message
|
423
411
|
assert_equal data, message.body
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
@client.commit 'tx2'
|
438
|
-
}
|
412
|
+
@client.begin 'tx2'
|
413
|
+
case @client.protocol()
|
414
|
+
when Stomp::SPL_10
|
415
|
+
@client.acknowledge message, :transaction => 'tx2'
|
416
|
+
checkEmsg(@client)
|
417
|
+
when Stomp::SPL_11
|
418
|
+
@client.acknowledge message, :transaction => 'tx2', :subscription => message.headers['subscription']
|
419
|
+
checkEmsg(@client)
|
420
|
+
else # 1.2+
|
421
|
+
@client.acknowledge message, :transaction => 'tx2', :id => message.headers['ack']
|
422
|
+
checkEmsg(@client)
|
423
|
+
end
|
424
|
+
@client.commit 'tx2'
|
439
425
|
checkEmsg(@client)
|
440
426
|
@client.close
|
441
427
|
@client = nil
|
@@ -496,16 +482,14 @@ class TestClient < Test::Unit::TestCase
|
|
496
482
|
msg = nil
|
497
483
|
dest = make_destination
|
498
484
|
Thread.new(@client) do |acli|
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
end
|
508
|
-
}
|
485
|
+
if acli.protocol() == Stomp::SPL_10
|
486
|
+
acli.subscribe(dest) { |m| msg = m }
|
487
|
+
else
|
488
|
+
acli.subscribe(dest, :id => acli.uuid()) { |m| msg = m }
|
489
|
+
end
|
490
|
+
Timeout::timeout(4) do
|
491
|
+
sleep 0.01 until msg
|
492
|
+
end
|
509
493
|
end
|
510
494
|
#
|
511
495
|
@client.publish(dest, message_text)
|
@@ -523,28 +507,26 @@ class TestClient < Test::Unit::TestCase
|
|
523
507
|
1.upto(@max_threads) do |tnum|
|
524
508
|
# Threads within threads .....
|
525
509
|
Thread.new(@client) do |acli|
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
end
|
547
|
-
}
|
510
|
+
# this is ugly .....
|
511
|
+
if acli.protocol() == Stomp::SPL_10
|
512
|
+
acli.subscribe(dest) { |m|
|
513
|
+
_ = m
|
514
|
+
lock.synchronize do
|
515
|
+
msg_ctr += 1
|
516
|
+
end
|
517
|
+
# Simulate message processing
|
518
|
+
sleep 0.05
|
519
|
+
}
|
520
|
+
else
|
521
|
+
acli.subscribe(dest, :id => acli.uuid()) { |m|
|
522
|
+
_ = m
|
523
|
+
lock.synchronize do
|
524
|
+
msg_ctr += 1
|
525
|
+
end
|
526
|
+
# Simulate message processing
|
527
|
+
sleep 0.05
|
528
|
+
}
|
529
|
+
end
|
548
530
|
end
|
549
531
|
end
|
550
532
|
#
|
@@ -620,17 +602,18 @@ class TestClient < Test::Unit::TestCase
|
|
620
602
|
# test max redeliveries is not broken (6c2c1c1)
|
621
603
|
def test_max_redeliveries
|
622
604
|
@client.close
|
623
|
-
|
624
|
-
|
625
|
-
|
605
|
+
2.upto(2) do |max_re|
|
606
|
+
rdmsg = "To Be Redelivered: #{max_re.to_s}"
|
607
|
+
dest = make_destination + ".#{max_re.to_s}"
|
626
608
|
@client = get_client()
|
627
|
-
sid =
|
609
|
+
sid = "sid_max_redeliveries_#{max_re.to_s}"
|
628
610
|
received = nil
|
629
611
|
rm_actual = 0
|
630
612
|
sh = @client.protocol() == Stomp::SPL_10 ? {} : {:id => sid}
|
631
613
|
@client.subscribe(dest, sh) {|msg|
|
632
614
|
rm_actual += 1
|
633
|
-
@client.unreceive(msg, :max_redeliveries => max_re
|
615
|
+
@client.unreceive(msg, :max_redeliveries => max_re,
|
616
|
+
:dead_letter_queue => make_dlq())
|
634
617
|
received = msg if rm_actual - 1 == max_re
|
635
618
|
}
|
636
619
|
@client.publish(dest, rdmsg)
|
@@ -641,7 +624,8 @@ class TestClient < Test::Unit::TestCase
|
|
641
624
|
assert_equal max_re, rm_actual - 1
|
642
625
|
@client.close
|
643
626
|
end
|
644
|
-
end
|
627
|
+
end unless ENV['STOMP_ARTEMIS'] # need to investigate this, but skip
|
628
|
+
# Artemis for now
|
645
629
|
|
646
630
|
# test issue99, OK values
|
647
631
|
def test_cli_iss99_ok
|
@@ -650,10 +634,8 @@ class TestClient < Test::Unit::TestCase
|
|
650
634
|
#
|
651
635
|
ok_vals = dflt_data_ok()
|
652
636
|
ok_vals.each do |hsv|
|
653
|
-
|
654
|
-
|
655
|
-
cli.close
|
656
|
-
}
|
637
|
+
cli = Stomp::Client.open(hsv)
|
638
|
+
cli.close
|
657
639
|
end
|
658
640
|
end
|
659
641
|
|
@@ -670,6 +652,24 @@ class TestClient < Test::Unit::TestCase
|
|
670
652
|
end
|
671
653
|
end
|
672
654
|
|
655
|
+
def test_cli_nodest_sub
|
656
|
+
assert_raise Stomp::Error::DestinationRequired do
|
657
|
+
@client.subscribe(nil) {|msg| puts msg}
|
658
|
+
end
|
659
|
+
end
|
660
|
+
|
661
|
+
def test_cli_nodest_unsub
|
662
|
+
assert_raise Stomp::Error::DestinationRequired do
|
663
|
+
@client.unsubscribe(nil)
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
667
|
+
def test_cli_nodest_pub
|
668
|
+
assert_raise Stomp::Error::DestinationRequired do
|
669
|
+
@client.publish(nil, "msg")
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
673
673
|
private
|
674
674
|
def message_text
|
675
675
|
name = caller_method_name unless name
|