stomp 1.4.4 → 1.4.5
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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +13 -0
- data/README.md +96 -100
- data/examples/EXAMPLES.md +251 -0
- data/examples/amqdurasub.rb +14 -17
- data/examples/artemis/cliwaiter_not_reliable.rb +12 -5
- data/examples/artemis/{cliwaiter_reliable.rb → cliwaiter_reliable_hb.rb} +24 -23
- data/examples/client_conndisc.rb +66 -0
- data/examples/client_putget.rb +94 -0
- data/examples/conn_conndisc.rb +102 -0
- data/examples/conn_putget.rb +124 -0
- data/examples/contrib.sh +2 -3
- data/examples/contributors.rb +26 -14
- data/examples/examplogger.rb +1 -1
- data/examples/{consumer.rb → historical/consumer.rb} +0 -0
- data/examples/{publisher.rb → historical/publisher.rb} +0 -0
- data/examples/{topic_consumer.rb → historical/topic_consumer.rb} +0 -0
- data/examples/{topic_publisher.rb → historical/topic_publisher.rb} +0 -0
- data/examples/logexamp.rb +23 -14
- data/examples/putget_file.rb +79 -0
- data/examples/{putget11_rh1.rb → putget_rephdrs.rb} +16 -15
- data/examples/ssl/SSL.md +189 -0
- data/examples/{ssl_ctxoptions.rb → ssl/misc/ssl_ctxoptions.rb} +23 -14
- data/examples/ssl/misc/ssl_newparm.rb +53 -0
- data/examples/ssl/misc/ssl_ucx_default_ciphers.rb +54 -0
- data/examples/ssl/ssl_common.rb +96 -0
- data/examples/ssl/sslexall.sh +17 -0
- data/examples/{ssl_uc1.rb → ssl/uc1/ssl_uc1.rb} +15 -11
- data/examples/ssl/uc1/ssl_uc1_ciphers.rb +60 -0
- data/examples/{ssl_uc2.rb → ssl/uc2/ssl_uc2.rb} +17 -10
- data/examples/ssl/uc2/ssl_uc2_ciphers.rb +67 -0
- data/examples/{ssl_uc3.rb → ssl/uc3/ssl_uc3.rb} +15 -16
- data/examples/ssl/uc3/ssl_uc3_ciphers.rb +65 -0
- data/examples/{ssl_uc4.rb → ssl/uc4/ssl_uc4.rb} +15 -15
- data/examples/ssl/uc4/ssl_uc4_ciphers.rb +66 -0
- data/examples/stomp_common.rb +97 -0
- data/lib/connection/netio.rb +83 -37
- data/lib/connection/utf8.rb +0 -7
- data/lib/connection/utils.rb +4 -1
- data/lib/stomp/client.rb +5 -1
- data/lib/stomp/connection.rb +25 -15
- data/lib/stomp/constants.rb +109 -0
- data/lib/stomp/errors.rb +11 -0
- data/lib/stomp/sslparams.rb +3 -4
- data/lib/stomp/version.rb +2 -2
- data/stomp.gemspec +31 -37
- data/test/test_anonymous.rb +4 -0
- data/test/test_client.rb +2 -0
- data/test/test_connection.rb +4 -0
- data/test/test_connection1p.rb +2 -4
- data/test/test_helper.rb +11 -0
- metadata +30 -36
- data/examples/artemis/artlogger.rb +0 -41
- data/examples/client11_ex1.rb +0 -89
- data/examples/client11_putget1.rb +0 -71
- data/examples/conn11_ex1.rb +0 -112
- data/examples/conn11_ex2.rb +0 -87
- data/examples/conn11_hb1.rb +0 -57
- data/examples/consume_file.rb +0 -63
- data/examples/get11conn_ex1.rb +0 -117
- data/examples/get11conn_ex2.rb +0 -77
- data/examples/lflogger.rb +0 -316
- data/examples/logexamp_ssl.rb +0 -81
- data/examples/publish_file.rb +0 -76
- data/examples/publish_file_conn.rb +0 -75
- data/examples/put11conn_ex1.rb +0 -56
- data/examples/ssl_common.rb +0 -73
- data/examples/ssl_newparm.rb +0 -43
- data/examples/ssl_uc1_ciphers.rb +0 -53
- data/examples/ssl_uc2_ciphers.rb +0 -60
- data/examples/ssl_uc3_ciphers.rb +0 -64
- data/examples/ssl_uc4_ciphers.rb +0 -65
- data/examples/ssl_ucx_default_ciphers.rb +0 -41
- data/examples/stomp11_common.rb +0 -54
data/test/test_anonymous.rb
CHANGED
@@ -258,6 +258,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
258
258
|
def test_thread_hang_one
|
259
259
|
received = nil
|
260
260
|
Thread.new(@conn) do |amq|
|
261
|
+
no_rep_error()
|
261
262
|
while true
|
262
263
|
received = amq.receive
|
263
264
|
end
|
@@ -277,6 +278,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
277
278
|
received = nil
|
278
279
|
max_sleep = (RUBY_VERSION =~ /1\.8/) ? 10 : 1
|
279
280
|
Thread.new(@conn) do |amq|
|
281
|
+
no_rep_error()
|
280
282
|
while true
|
281
283
|
received = amq.poll
|
282
284
|
# One message is needed
|
@@ -302,6 +304,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
302
304
|
#
|
303
305
|
1.upto(@max_threads) do |tnum|
|
304
306
|
Thread.new(@conn) do |amq|
|
307
|
+
no_rep_error()
|
305
308
|
while true
|
306
309
|
_ = amq.receive
|
307
310
|
lock.synchronize do
|
@@ -342,6 +345,7 @@ class TestAnonymous < Test::Unit::TestCase
|
|
342
345
|
#
|
343
346
|
1.upto(@max_threads) do |tnum|
|
344
347
|
Thread.new(@conn) do |amq|
|
348
|
+
no_rep_error()
|
345
349
|
while true
|
346
350
|
received = amq.poll
|
347
351
|
if received
|
data/test/test_client.rb
CHANGED
@@ -482,6 +482,7 @@ class TestClient < Test::Unit::TestCase
|
|
482
482
|
msg = nil
|
483
483
|
dest = make_destination
|
484
484
|
Thread.new(@client) do |acli|
|
485
|
+
no_rep_error()
|
485
486
|
if acli.protocol() == Stomp::SPL_10
|
486
487
|
acli.subscribe(dest) { |m| msg = m }
|
487
488
|
else
|
@@ -507,6 +508,7 @@ class TestClient < Test::Unit::TestCase
|
|
507
508
|
1.upto(@max_threads) do |tnum|
|
508
509
|
# Threads within threads .....
|
509
510
|
Thread.new(@client) do |acli|
|
511
|
+
no_rep_error()
|
510
512
|
# this is ugly .....
|
511
513
|
if acli.protocol() == Stomp::SPL_10
|
512
514
|
acli.subscribe(dest) { |m|
|
data/test/test_connection.rb
CHANGED
@@ -258,6 +258,7 @@ class TestConnection < Test::Unit::TestCase
|
|
258
258
|
def test_thread_hang_one
|
259
259
|
received = nil
|
260
260
|
Thread.new(@conn) do |amq|
|
261
|
+
no_rep_error()
|
261
262
|
while true
|
262
263
|
received = amq.receive
|
263
264
|
end
|
@@ -277,6 +278,7 @@ class TestConnection < Test::Unit::TestCase
|
|
277
278
|
received = nil
|
278
279
|
max_sleep = (RUBY_VERSION =~ /1\.8/) ? 10 : 1
|
279
280
|
Thread.new(@conn) do |amq|
|
281
|
+
no_rep_error()
|
280
282
|
while true
|
281
283
|
received = amq.poll
|
282
284
|
# One message is needed
|
@@ -302,6 +304,7 @@ class TestConnection < Test::Unit::TestCase
|
|
302
304
|
#
|
303
305
|
1.upto(@max_threads) do |tnum|
|
304
306
|
Thread.new(@conn) do |amq|
|
307
|
+
no_rep_error()
|
305
308
|
while true
|
306
309
|
_ = amq.receive
|
307
310
|
lock.synchronize do
|
@@ -342,6 +345,7 @@ class TestConnection < Test::Unit::TestCase
|
|
342
345
|
#
|
343
346
|
1.upto(@max_threads) do |tnum|
|
344
347
|
Thread.new(@conn) do |amq|
|
348
|
+
no_rep_error()
|
345
349
|
while true
|
346
350
|
received = amq.poll
|
347
351
|
if received
|
data/test/test_connection1p.rb
CHANGED
@@ -111,9 +111,8 @@ class TestConnection1P < Test::Unit::TestCase
|
|
111
111
|
#
|
112
112
|
cha = get_conn_headers()
|
113
113
|
cha["heart-beat"] = "10,10,20" # Bad header Heartbeats
|
114
|
-
conn = nil
|
115
114
|
assert_raise Stomp::Error::InvalidHeartBeatHeaderError do
|
116
|
-
|
115
|
+
_ = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
|
117
116
|
end
|
118
117
|
end
|
119
118
|
|
@@ -123,9 +122,8 @@ class TestConnection1P < Test::Unit::TestCase
|
|
123
122
|
#
|
124
123
|
cha = get_conn_headers()
|
125
124
|
cha["heart-beat"] = "a,10" # Bad header Heartbeats
|
126
|
-
conn = nil
|
127
125
|
assert_raise Stomp::Error::InvalidHeartBeatHeaderError do
|
128
|
-
|
126
|
+
_ = Stomp::Connection.open(user, passcode, host, port, false, 5, cha)
|
129
127
|
end
|
130
128
|
end
|
131
129
|
|
data/test/test_helper.rb
CHANGED
@@ -78,6 +78,7 @@ module TestBase
|
|
78
78
|
:usecrlf => get_crlf(),
|
79
79
|
}
|
80
80
|
conn = Stomp::Connection.open(hash)
|
81
|
+
no_rep_error()
|
81
82
|
conn
|
82
83
|
end
|
83
84
|
|
@@ -93,6 +94,7 @@ module TestBase
|
|
93
94
|
:usecrlf => get_crlf(),
|
94
95
|
}
|
95
96
|
conn = Stomp::Connection.open(hash)
|
97
|
+
no_rep_error()
|
96
98
|
conn
|
97
99
|
end
|
98
100
|
|
@@ -108,9 +110,18 @@ module TestBase
|
|
108
110
|
:usecrlf => get_crlf(),
|
109
111
|
}
|
110
112
|
conn = Stomp::Connection.new(hash)
|
113
|
+
no_rep_error()
|
111
114
|
conn
|
112
115
|
end
|
113
116
|
|
117
|
+
#
|
118
|
+
def no_rep_error()
|
119
|
+
ct = Thread::current
|
120
|
+
if ct.respond_to?(:report_on_exception=)
|
121
|
+
ct.report_on_exception=false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
114
125
|
# Get a Stomp Client.
|
115
126
|
def get_client()
|
116
127
|
hash = { :hosts => [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stomp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian McCallister
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2018-10-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -63,45 +63,39 @@ files:
|
|
63
63
|
- adhoc/stomp_adhoc_common.rb
|
64
64
|
- bin/catstomp
|
65
65
|
- bin/stompcat
|
66
|
+
- examples/EXAMPLES.md
|
66
67
|
- examples/amqdurasub.rb
|
67
|
-
- examples/artemis/artlogger.rb
|
68
68
|
- examples/artemis/cliwaiter_not_reliable.rb
|
69
|
-
- examples/artemis/
|
70
|
-
- examples/
|
71
|
-
- examples/
|
72
|
-
- examples/
|
73
|
-
- examples/
|
74
|
-
- examples/conn11_hb1.rb
|
75
|
-
- examples/consume_file.rb
|
76
|
-
- examples/consumer.rb
|
69
|
+
- examples/artemis/cliwaiter_reliable_hb.rb
|
70
|
+
- examples/client_conndisc.rb
|
71
|
+
- examples/client_putget.rb
|
72
|
+
- examples/conn_conndisc.rb
|
73
|
+
- examples/conn_putget.rb
|
77
74
|
- examples/contrib.sh
|
78
75
|
- examples/contributors.rb
|
79
76
|
- examples/examplogger.rb
|
80
|
-
- examples/
|
81
|
-
- examples/
|
82
|
-
- examples/
|
77
|
+
- examples/historical/consumer.rb
|
78
|
+
- examples/historical/publisher.rb
|
79
|
+
- examples/historical/topic_consumer.rb
|
80
|
+
- examples/historical/topic_publisher.rb
|
83
81
|
- examples/logexamp.rb
|
84
|
-
- examples/
|
85
|
-
- examples/
|
86
|
-
- examples/
|
87
|
-
- examples/
|
88
|
-
- examples/
|
89
|
-
- examples/
|
90
|
-
- examples/ssl_common.rb
|
91
|
-
- examples/
|
92
|
-
- examples/
|
93
|
-
- examples/
|
94
|
-
- examples/
|
95
|
-
- examples/
|
96
|
-
- examples/
|
97
|
-
- examples/
|
98
|
-
- examples/
|
99
|
-
- examples/
|
100
|
-
- examples/
|
101
|
-
- examples/ssl_ucx_default_ciphers.rb
|
102
|
-
- examples/stomp11_common.rb
|
103
|
-
- examples/topic_consumer.rb
|
104
|
-
- examples/topic_publisher.rb
|
82
|
+
- examples/putget_file.rb
|
83
|
+
- examples/putget_rephdrs.rb
|
84
|
+
- examples/ssl/SSL.md
|
85
|
+
- examples/ssl/misc/ssl_ctxoptions.rb
|
86
|
+
- examples/ssl/misc/ssl_newparm.rb
|
87
|
+
- examples/ssl/misc/ssl_ucx_default_ciphers.rb
|
88
|
+
- examples/ssl/ssl_common.rb
|
89
|
+
- examples/ssl/sslexall.sh
|
90
|
+
- examples/ssl/uc1/ssl_uc1.rb
|
91
|
+
- examples/ssl/uc1/ssl_uc1_ciphers.rb
|
92
|
+
- examples/ssl/uc2/ssl_uc2.rb
|
93
|
+
- examples/ssl/uc2/ssl_uc2_ciphers.rb
|
94
|
+
- examples/ssl/uc3/ssl_uc3.rb
|
95
|
+
- examples/ssl/uc3/ssl_uc3_ciphers.rb
|
96
|
+
- examples/ssl/uc4/ssl_uc4.rb
|
97
|
+
- examples/ssl/uc4/ssl_uc4_ciphers.rb
|
98
|
+
- examples/stomp_common.rb
|
105
99
|
- lib/client/utils.rb
|
106
100
|
- lib/connection/heartbeats.rb
|
107
101
|
- lib/connection/netio.rb
|
@@ -160,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
154
|
version: '0'
|
161
155
|
requirements: []
|
162
156
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.6
|
157
|
+
rubygems_version: 2.7.6
|
164
158
|
signing_key:
|
165
159
|
specification_version: 4
|
166
160
|
summary: Ruby client for the Stomp messaging protocol
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'logger' # use the standard Ruby logger .....
|
4
|
-
#
|
5
|
-
class Slogger
|
6
|
-
|
7
|
-
# Initialize a new callback logger instance.
|
8
|
-
def initialize(init_parms = nil)
|
9
|
-
_init
|
10
|
-
@log.info("Logger initialization complete.")
|
11
|
-
end
|
12
|
-
|
13
|
-
def _init
|
14
|
-
@log = Logger::new(STDERR) # User preference
|
15
|
-
@log.level = Logger::DEBUG # User preference
|
16
|
-
end
|
17
|
-
|
18
|
-
# Log connecting events
|
19
|
-
def on_connecting(parms)
|
20
|
-
begin
|
21
|
-
@log.debug "Connecting: #{parms}"
|
22
|
-
rescue Exception => ex
|
23
|
-
@log.debug "Connecting oops"
|
24
|
-
print ex.backtrace.join("\n")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Log connected events
|
29
|
-
def on_connected(parms)
|
30
|
-
begin
|
31
|
-
@log.debug "Connected: #{parms}"
|
32
|
-
rescue Exception => ex
|
33
|
-
@log.debug "Connected oops"
|
34
|
-
print ex.backtrace.join("\n")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
end # of class
|
41
|
-
|
data/examples/client11_ex1.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
#
|
4
|
-
# The current require dance for different Ruby versions.
|
5
|
-
# Change this to suit your requirements.
|
6
|
-
#
|
7
|
-
if Kernel.respond_to?(:require_relative)
|
8
|
-
require_relative("./stomp11_common")
|
9
|
-
else
|
10
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
-
require "stomp11_common"
|
12
|
-
end
|
13
|
-
include Stomp11Common
|
14
|
-
|
15
|
-
#
|
16
|
-
# == Stomp 1.1 Client Example 1
|
17
|
-
#
|
18
|
-
# Purpose: to demonstrate a connect and disconnect sequence using Stomp 1.1
|
19
|
-
# with the Stomp#Client interface.
|
20
|
-
#
|
21
|
-
class Client11Example1
|
22
|
-
# Initialize.
|
23
|
-
def initialize
|
24
|
-
end
|
25
|
-
# Run example.
|
26
|
-
def run
|
27
|
-
# Note: Stomp#Client does not provide a positional set of parameters that
|
28
|
-
# contain a 'connect_headers' parameter. To use the Stomp#Client interface
|
29
|
-
# you _must_ use a 'hashed' set of parameters.
|
30
|
-
#
|
31
|
-
# Create connection headers
|
32
|
-
# =========================
|
33
|
-
#
|
34
|
-
# The two headers used here are _required_ by the specification.
|
35
|
-
#
|
36
|
-
client_hdrs = {"accept-version" => "1.1", # Demand a 1.1 connection (use a CSV list if you will consider multiple versions)
|
37
|
-
"host" => virt_host, # The 1.1 vhost (could be different than connection host)
|
38
|
-
} # No heartbeats here: there will be none for this connection
|
39
|
-
#
|
40
|
-
# Create the connect hash.
|
41
|
-
# ========================
|
42
|
-
#
|
43
|
-
client_hash = { :hosts => [
|
44
|
-
{:login => login, :passcode => passcode, :host => host, :port => port},
|
45
|
-
],
|
46
|
-
:connect_headers => client_hdrs,
|
47
|
-
}
|
48
|
-
#
|
49
|
-
# Get a connection
|
50
|
-
# ================
|
51
|
-
#
|
52
|
-
client = Stomp::Client.new(client_hash)
|
53
|
-
puts "Client Connect complete"
|
54
|
-
#
|
55
|
-
# Let's just do some sanity checks, and look around.
|
56
|
-
#
|
57
|
-
raise "Connection failed!!" unless client.open?
|
58
|
-
#
|
59
|
-
# Is this really a 1.1 conection? (For clients, 'protocol' is a public method.
|
60
|
-
# The value will be '1.0' for those types of connections.)
|
61
|
-
#
|
62
|
-
raise "Unexpected protocol level" if client.protocol() != Stomp::SPL_11
|
63
|
-
#
|
64
|
-
# The broker _could_ have returned an ERROR frame (unlikely).
|
65
|
-
# For clients, 'connection_frame' is a public method.
|
66
|
-
#
|
67
|
-
raise "Connect error: #{client.connection_frame().body}" if client.connection_frame().command == Stomp::CMD_ERROR
|
68
|
-
#
|
69
|
-
# Examine the CONNECT response (the connection_frame()).
|
70
|
-
#
|
71
|
-
puts "Connected Headers required to be present:"
|
72
|
-
puts "Connect version - \t#{client.connection_frame().headers['version']}"
|
73
|
-
puts
|
74
|
-
puts "Connected Headers that are optional:"
|
75
|
-
puts "Connect server - \t\t#{client.connection_frame().headers['server']}"
|
76
|
-
puts "Session ID - \t\t\t#{client.connection_frame().headers['session']}"
|
77
|
-
puts "Server requested heartbeats - \t#{client.connection_frame().headers['heart-beat']}"
|
78
|
-
#
|
79
|
-
# Finally close
|
80
|
-
# =============
|
81
|
-
#
|
82
|
-
client.close # Business as usual, just like 1.0
|
83
|
-
puts "Client close complete"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
#
|
87
|
-
e = Client11Example1.new
|
88
|
-
e.run
|
89
|
-
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
#
|
4
|
-
# The current require dance for different Ruby versions.
|
5
|
-
# Change this to suit your requirements.
|
6
|
-
#
|
7
|
-
if Kernel.respond_to?(:require_relative)
|
8
|
-
require_relative("./stomp11_common")
|
9
|
-
else
|
10
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
-
require "stomp11_common"
|
12
|
-
end
|
13
|
-
include Stomp11Common
|
14
|
-
|
15
|
-
#
|
16
|
-
# == Stomp 1.1 Client Putter/Getter Example 1
|
17
|
-
#
|
18
|
-
# This is much like sending and receiving with a Stomp::Connection.
|
19
|
-
#
|
20
|
-
class Client11PutGet1
|
21
|
-
# Initialize.
|
22
|
-
def initialize
|
23
|
-
end
|
24
|
-
# Run example.
|
25
|
-
def run
|
26
|
-
#
|
27
|
-
client_hdrs = {"accept-version" => "1.1", # Demand a 1.1 connection (use a CSV list if you will consider multiple versions)
|
28
|
-
"host" => virt_host, # The 1.1 vhost (could be different than connection host)
|
29
|
-
} # No heartbeats here: there will be none for this connection
|
30
|
-
#
|
31
|
-
client_hash = { :hosts => [
|
32
|
-
{:login => login, :passcode => passcode, :host => host, :port => port},
|
33
|
-
],
|
34
|
-
:connect_headers => client_hdrs,
|
35
|
-
}
|
36
|
-
#
|
37
|
-
client = Stomp::Client.new(client_hash)
|
38
|
-
puts "Client Connect complete"
|
39
|
-
#
|
40
|
-
raise "Unexpected protocol level" if client.protocol() != Stomp::SPL_11
|
41
|
-
#
|
42
|
-
qname = "/queue/client.nodea.nodeb.nodec"
|
43
|
-
data = "message payload: #{Time.now.to_f}"
|
44
|
-
headers = {}
|
45
|
-
# Send it
|
46
|
-
client.publish qname, data
|
47
|
-
puts "Publish complete"
|
48
|
-
# Receive
|
49
|
-
uuid = client.uuid() # uuid for Stomp::Client is a public method
|
50
|
-
message = nil
|
51
|
-
# Clients must pass a receive block. This is business as usual, required for 1.0.
|
52
|
-
# For 1.1, a unique subscription id is required.
|
53
|
-
client.subscribe(qname, {'id' => uuid}) {|m|
|
54
|
-
message = m
|
55
|
-
}
|
56
|
-
sleep 0.1 until message # Wait for completion
|
57
|
-
puts "Subscribe and receive complete"
|
58
|
-
# Unsubscribe, with the unique id
|
59
|
-
client.unsubscribe qname, {'id' => uuid}
|
60
|
-
# Sanity checks for this example ....
|
61
|
-
raise "Unexpected data" if data != message.body
|
62
|
-
raise "Bad subscription header" if uuid != message.headers['subscription']
|
63
|
-
#
|
64
|
-
client.close # Business as usual, just like 1.0
|
65
|
-
puts "Client close complete"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
#
|
69
|
-
e = Client11PutGet1.new
|
70
|
-
e.run
|
71
|
-
|
data/examples/conn11_ex1.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
#
|
4
|
-
# The current require dance for different Ruby versions.
|
5
|
-
# Change this to suit your requirements.
|
6
|
-
#
|
7
|
-
if Kernel.respond_to?(:require_relative)
|
8
|
-
require_relative("./stomp11_common")
|
9
|
-
else
|
10
|
-
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
-
require "stomp11_common"
|
12
|
-
end
|
13
|
-
include Stomp11Common
|
14
|
-
|
15
|
-
#
|
16
|
-
# == Stomp 1.1 Connection Example 1
|
17
|
-
#
|
18
|
-
# Purpose: to demonstrate a connect and disconnect sequence using Stomp 1.1.
|
19
|
-
#
|
20
|
-
# Note: this example assumes that you have at least the 1.2.0 gem release
|
21
|
-
# installed.
|
22
|
-
#
|
23
|
-
# When you:
|
24
|
-
#
|
25
|
-
# * Use a Stomp 1.1 compliant broker
|
26
|
-
# * Want a Stomp 1.1 level connection and functionality
|
27
|
-
#
|
28
|
-
# then your code *must* specifically request that environment.
|
29
|
-
#
|
30
|
-
# You need to supply all of the normal values expected of course:
|
31
|
-
#
|
32
|
-
# * login - the user name
|
33
|
-
# * passcode - the password
|
34
|
-
# * host - the host to connect to
|
35
|
-
# * port - the port to connect to
|
36
|
-
#
|
37
|
-
# Additionaly you are required to supply the 1.1 connection data as documented
|
38
|
-
# in the Stomp 1.1 specification: http://stomp.github.com/stomp-specification-1.1.html
|
39
|
-
# You are urged to become familiar with the spec. It is a short document.
|
40
|
-
#
|
41
|
-
# This includes:
|
42
|
-
#
|
43
|
-
# * The Stomp version(s) you wish the broker to consider
|
44
|
-
# * The broker vhost to connect to
|
45
|
-
#
|
46
|
-
# You may optionally specify other 1.1 data:
|
47
|
-
#
|
48
|
-
# * heartbeat request
|
49
|
-
#
|
50
|
-
# Using the stomp gem, you can specify this data in the "connect_headers" Hash
|
51
|
-
# parameter or a paramaterized connection request. This example uses a
|
52
|
-
# parameterized request.
|
53
|
-
#
|
54
|
-
class Connection11Example1
|
55
|
-
# Initialize
|
56
|
-
def initialize
|
57
|
-
end
|
58
|
-
# Run example
|
59
|
-
def run
|
60
|
-
#
|
61
|
-
# Create connection headers
|
62
|
-
# =========================
|
63
|
-
#
|
64
|
-
# The two headers used here are _required_ by the specification.
|
65
|
-
#
|
66
|
-
conn_hdrs = {"accept-version" => "1.1", # Demand a 1.1 connection (use a CSV list if you will consider multiple versions)
|
67
|
-
"host" => virt_host, # The 1.1 vhost (could be different than connection host)
|
68
|
-
} # No heartbeats here: there will be none for this connection
|
69
|
-
#
|
70
|
-
# Get a connection
|
71
|
-
# ================
|
72
|
-
#
|
73
|
-
conn = Stomp::Connection.new(login, passcode, host, port, # Normal connect parms
|
74
|
-
false, # Not reliable, the default for a parameter connection
|
75
|
-
5, # Connect redelay, the default
|
76
|
-
conn_hdrs) # The 1.1 connection parameters
|
77
|
-
puts "Connection connect complete"
|
78
|
-
#
|
79
|
-
# Let's just do some sanity checks, and look around.
|
80
|
-
#
|
81
|
-
raise "Connection failed!!" unless conn.open?
|
82
|
-
#
|
83
|
-
# Is this really a 1.1 conection? ('protocol' is a read only connection
|
84
|
-
# instance variable. The value will be '1.0' for those types of connections.)
|
85
|
-
#
|
86
|
-
raise "Unexpected protocol level" if conn.protocol != Stomp::SPL_11
|
87
|
-
#
|
88
|
-
# The broker _could_ have returned an ERROR frame (unlikely).
|
89
|
-
#
|
90
|
-
raise "Connect error: #{conn.connection_frame.body}" if conn.connection_frame.command == Stomp::CMD_ERROR
|
91
|
-
#
|
92
|
-
# Examine the CONNECT response (the connection_frame).
|
93
|
-
#
|
94
|
-
puts "Connected Headers required to be present:"
|
95
|
-
puts "Connect version - \t#{conn.connection_frame.headers['version']}"
|
96
|
-
puts
|
97
|
-
puts "Connected Headers that are optional:"
|
98
|
-
puts "Connect server - \t\t#{conn.connection_frame.headers['server']}"
|
99
|
-
puts "Session ID - \t\t\t#{conn.connection_frame.headers['session']}"
|
100
|
-
puts "Server requested heartbeats - \t#{conn.connection_frame.headers['heart-beat']}"
|
101
|
-
#
|
102
|
-
# Finally disconnect
|
103
|
-
# ==================
|
104
|
-
#
|
105
|
-
conn.disconnect # Business as usual, just like 1.0
|
106
|
-
puts "Connection disconnect complete"
|
107
|
-
end
|
108
|
-
end
|
109
|
-
#
|
110
|
-
e = Connection11Example1.new
|
111
|
-
e.run
|
112
|
-
|