stomp 1.2.8 → 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +9 -0
- data/README.rdoc +14 -11
- data/lib/client/utils.rb +69 -7
- data/lib/connection/utf8.rb +1 -1
- data/lib/stomp/client.rb +12 -52
- data/lib/stomp/version.rb +1 -1
- data/stomp.gemspec +2 -2
- data/test/test_connection.rb +1 -5
- data/test/test_connection1p.rb +19 -1
- data/test/test_message.rb +4 -1
- metadata +4 -4
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 1.2.9 20130328
|
2
|
+
|
3
|
+
* Refactoring and documentation updates (glennr)
|
4
|
+
* Fix test encoding for Ruby 2.0+
|
5
|
+
* Fixes to tests due to :suppress_content_length fix
|
6
|
+
* Issue #50 Stomp::Client reconnects fail
|
7
|
+
* Correctly honor :suppress_content_length with 1.1 (JP Hastings-Spital)
|
8
|
+
* Fix reference to client.publish rather than client.send (JP Hastings-Spital)
|
9
|
+
|
1
10
|
== 1.2.8 20121228
|
2
11
|
|
3
12
|
* Fix inverted encode / decode logic (fairly major 1.1+ bug)
|
data/README.rdoc
CHANGED
@@ -10,6 +10,7 @@ An implementation of the Stomp protocol for Ruby. See:
|
|
10
10
|
|
11
11
|
===New
|
12
12
|
|
13
|
+
* Gem version 1.2.9. Miscellaneous fixes and changes. See _CHANGELOG.rdoc_ for details.
|
13
14
|
* Gem version 1.2.8. Stomp 1.1+ header codec inversion fix, test refactoring. See _CHANGELOG.rdoc_ for details.
|
14
15
|
* Gem version 1.2.7. Stomp 1.2 support and miscellaneous fixes. See _CHANGELOG.rdoc_ for details.
|
15
16
|
* Gem version 1.2.6. Miscellaneous fixes and changes. See _CHANGELOG.rdoc_ for details.
|
@@ -30,7 +31,7 @@ See _CHANGELOG.rdoc_ for details.
|
|
30
31
|
{:login => "login1", :passcode => "passcode1", :host => "remotehost1", :port => 61612, :ssl => true},
|
31
32
|
# First failover connect is to remotehost2
|
32
33
|
{:login => "login2", :passcode => "passcode2", :host => "remotehost2", :port => 61613, :ssl => false},
|
33
|
-
|
34
|
+
|
34
35
|
],
|
35
36
|
# These are the default parameters and do not need to be set
|
36
37
|
:reliable => true, # reliable (use failover)
|
@@ -50,17 +51,17 @@ See _CHANGELOG.rdoc_ for details.
|
|
50
51
|
:stompconn => false, # Use STOMP instead of CONNECT
|
51
52
|
:usecrlf => false, # Use CRLF command and header line ends (1.2+)
|
52
53
|
}
|
53
|
-
|
54
|
+
|
54
55
|
# for client
|
55
56
|
client = Stomp::Client.new(hash)
|
56
|
-
|
57
|
+
|
57
58
|
# for connection
|
58
59
|
connection = Stomp::Connection.new(hash)
|
59
|
-
|
60
|
+
|
60
61
|
===Positional Parameter Usage
|
61
62
|
|
62
|
-
client = Stomp::Client.new("
|
63
|
-
client.
|
63
|
+
client = Stomp::Client.new("user", "pass", "localhost", 61613)
|
64
|
+
client.publish("/queue/mine", "hello world!")
|
64
65
|
client.subscribe("/queue/mine") do |msg|
|
65
66
|
p msg
|
66
67
|
end
|
@@ -74,16 +75,16 @@ See _CHANGELOG.rdoc_ for details.
|
|
74
75
|
stomp://host.domain.tld:port
|
75
76
|
stomp://login:passcode@host:port
|
76
77
|
stomp://login:passcode@host.domain.tld:port
|
77
|
-
|
78
|
+
|
78
79
|
e.g. c = Stomp::Client.new(urlstring)
|
79
80
|
|
80
81
|
===Failover + SSL Example URL Usage
|
81
82
|
|
82
83
|
options = "initialReconnectDelay=5000&randomize=false&useExponentialBackOff=false"
|
83
|
-
|
84
|
+
|
84
85
|
# remotehost1 uses SSL, remotehost2 doesn't
|
85
86
|
client = Stomp::Client.new("failover:(stomp+ssl://login1:passcode1@remotehost1:61612,stomp://login2:passcode2@remotehost2:61613)?#{options}")
|
86
|
-
|
87
|
+
|
87
88
|
client.publish("/queue/mine", "hello world!")
|
88
89
|
client.subscribe("/queue/mine") do |msg|
|
89
90
|
p msg
|
@@ -91,7 +92,7 @@ See _CHANGELOG.rdoc_ for details.
|
|
91
92
|
|
92
93
|
===Historical Information
|
93
94
|
|
94
|
-
Up until March 2009 the project was maintained and primarily developed by Brian McCallister.
|
95
|
+
Up until March 2009 the project was maintained and primarily developed by Brian McCallister.
|
95
96
|
|
96
97
|
===Source Code and Project URLs
|
97
98
|
|
@@ -107,7 +108,7 @@ The following people have contributed to Stomp:
|
|
107
108
|
|
108
109
|
* Brian McCallister
|
109
110
|
* Glenn Rempe <glenn@rempe.us>
|
110
|
-
* jstrachan
|
111
|
+
* jstrachan
|
111
112
|
* Marius Mathiesen <marius.mathiesen@gmail.com>
|
112
113
|
* Johan S√∏rensen <johan@johansorensen.com>
|
113
114
|
* Thiago Morello
|
@@ -129,4 +130,6 @@ The following people have contributed to Stomp:
|
|
129
130
|
* Craig
|
130
131
|
* Tommy Bishop
|
131
132
|
* Jeremy Gailor
|
133
|
+
* JP Hastings-Spital
|
134
|
+
* Glenn Roberts
|
132
135
|
|
data/lib/client/utils.rb
CHANGED
@@ -9,6 +9,66 @@ module Stomp
|
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
+
def parse_hash_params(params)
|
13
|
+
return false unless params.is_a?(Hash)
|
14
|
+
|
15
|
+
@parameters = params
|
16
|
+
first_host = @parameters[:hosts][0]
|
17
|
+
@login = first_host[:login]
|
18
|
+
@passcode = first_host[:passcode]
|
19
|
+
@host = first_host[:host]
|
20
|
+
@port = first_host[:port] || Connection::default_port(first_host[:ssl])
|
21
|
+
@reliable = true
|
22
|
+
true
|
23
|
+
end
|
24
|
+
private :parse_hash_params
|
25
|
+
|
26
|
+
def parse_stomp_url(login)
|
27
|
+
regexp = /^stomp:\/\/#{url_regex}/ # e.g. stomp://login:passcode@host:port or stomp://host:port
|
28
|
+
return false unless login =~ regexp
|
29
|
+
|
30
|
+
@login = $2 || ""
|
31
|
+
@passcode = $3 || ""
|
32
|
+
@host = $4
|
33
|
+
@port = $5.to_i
|
34
|
+
@reliable = false
|
35
|
+
true
|
36
|
+
end
|
37
|
+
private :parse_stomp_url
|
38
|
+
|
39
|
+
# e.g. failover://(stomp://login1:passcode1@localhost:61616,stomp://login2:passcode2@remotehost:61617)?option1=param
|
40
|
+
def parse_failover_url(login)
|
41
|
+
regexp = /^failover:(\/\/)?\(stomp(\+ssl)?:\/\/#{url_regex}(,stomp(\+ssl)?:\/\/#{url_regex}\))+(\?(.*))?$/
|
42
|
+
return false unless login =~ regexp
|
43
|
+
|
44
|
+
first_host = {}
|
45
|
+
first_host[:ssl] = !$2.nil?
|
46
|
+
@login = first_host[:login] = $4 || ""
|
47
|
+
@passcode = first_host[:passcode] = $5 || ""
|
48
|
+
@host = first_host[:host] = $6
|
49
|
+
@port = first_host[:port] = $7.to_i || Connection::default_port(first_host[:ssl])
|
50
|
+
options = $16 || ""
|
51
|
+
parts = options.split(/&|=/)
|
52
|
+
options = Hash[*parts]
|
53
|
+
hosts = [first_host] + parse_hosts(login)
|
54
|
+
@parameters = {}
|
55
|
+
@parameters[:hosts] = hosts
|
56
|
+
@parameters.merge! filter_options(options)
|
57
|
+
@reliable = true
|
58
|
+
true
|
59
|
+
end
|
60
|
+
private :parse_failover_url
|
61
|
+
|
62
|
+
def parse_positional_params(login, passcode, host, port, reliable)
|
63
|
+
@login = login
|
64
|
+
@passcode = passcode
|
65
|
+
@host = host
|
66
|
+
@port = port.to_i
|
67
|
+
@reliable = reliable
|
68
|
+
true
|
69
|
+
end
|
70
|
+
private :parse_positional_params
|
71
|
+
|
12
72
|
# Set a subscription id in the headers hash if one does not already exist.
|
13
73
|
# For simplicities sake, all subscriptions have a subscription ID.
|
14
74
|
# setting an id in the SUBSCRIPTION header is described in the stomp protocol docs:
|
@@ -97,13 +157,15 @@ module Stomp
|
|
97
157
|
@listener_thread = Thread.start do
|
98
158
|
while true
|
99
159
|
message = @connection.receive
|
100
|
-
if message
|
101
|
-
if
|
102
|
-
listener
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
listener.
|
160
|
+
if message # AMQ specific?, nil message on multiple reconnects
|
161
|
+
if message.command == Stomp::CMD_MESSAGE
|
162
|
+
if listener = find_listener(message)
|
163
|
+
listener.call(message)
|
164
|
+
end
|
165
|
+
elsif message.command == Stomp::CMD_RECEIPT
|
166
|
+
if listener = @receipt_listeners[message.headers['receipt-id']]
|
167
|
+
listener.call(message)
|
168
|
+
end
|
107
169
|
end
|
108
170
|
end
|
109
171
|
end # while true
|
data/lib/connection/utf8.rb
CHANGED
data/lib/stomp/client.rb
CHANGED
@@ -12,8 +12,6 @@ module Stomp
|
|
12
12
|
# in that thread if you have much message volume.
|
13
13
|
class Client
|
14
14
|
|
15
|
-
public
|
16
|
-
|
17
15
|
# The login ID used by the client.
|
18
16
|
attr_reader :login
|
19
17
|
|
@@ -81,69 +79,31 @@ module Stomp
|
|
81
79
|
# e.g. c = Stomp::Client.new(urlstring)
|
82
80
|
#
|
83
81
|
def initialize(login = '', passcode = '', host = 'localhost', port = 61613, reliable = false, autoflush = false)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
first_host = @parameters[:hosts][0]
|
90
|
-
|
91
|
-
@login = first_host[:login]
|
92
|
-
@passcode = first_host[:passcode]
|
93
|
-
@host = first_host[:host]
|
94
|
-
@port = first_host[:port] || Connection::default_port(first_host[:ssl])
|
95
|
-
|
96
|
-
@reliable = true
|
97
|
-
elsif login =~ /^stomp:\/\/#{url_regex}/ # e.g. stomp://login:passcode@host:port or stomp://host:port
|
98
|
-
@login = $2 || ""
|
99
|
-
@passcode = $3 || ""
|
100
|
-
@host = $4
|
101
|
-
@port = $5.to_i
|
102
|
-
@reliable = false
|
103
|
-
elsif login =~ /^failover:(\/\/)?\(stomp(\+ssl)?:\/\/#{url_regex}(,stomp(\+ssl)?:\/\/#{url_regex}\))+(\?(.*))?$/
|
104
|
-
# e.g. failover://(stomp://login1:passcode1@localhost:61616,stomp://login2:passcode2@remotehost:61617)?option1=param
|
105
|
-
first_host = {}
|
106
|
-
first_host[:ssl] = !$2.nil?
|
107
|
-
@login = first_host[:login] = $4 || ""
|
108
|
-
@passcode = first_host[:passcode] = $5 || ""
|
109
|
-
@host = first_host[:host] = $6
|
110
|
-
@port = first_host[:port] = $7.to_i || Connection::default_port(first_host[:ssl])
|
111
|
-
|
112
|
-
options = $16 || ""
|
113
|
-
parts = options.split(/&|=/)
|
114
|
-
options = Hash[*parts]
|
115
|
-
|
116
|
-
hosts = [first_host] + parse_hosts(login)
|
117
|
-
|
118
|
-
@parameters = {}
|
119
|
-
@parameters[:hosts] = hosts
|
120
|
-
|
121
|
-
@parameters.merge! filter_options(options)
|
122
|
-
|
123
|
-
@reliable = true
|
124
|
-
else
|
125
|
-
@login = login
|
126
|
-
@passcode = passcode
|
127
|
-
@host = host
|
128
|
-
@port = port.to_i
|
129
|
-
@reliable = reliable
|
130
|
-
end
|
82
|
+
parse_hash_params(login) ||
|
83
|
+
parse_stomp_url(login) ||
|
84
|
+
parse_failover_url(login) ||
|
85
|
+
parse_positional_params(login, passcode, host, port, reliable)
|
131
86
|
|
132
87
|
check_arguments!()
|
133
88
|
|
134
89
|
@id_mutex = Mutex.new()
|
135
90
|
@ids = 1
|
136
91
|
|
92
|
+
create_connection(autoflush)
|
93
|
+
|
94
|
+
start_listeners()
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
def create_connection(autoflush)
|
137
99
|
if @parameters
|
138
100
|
@connection = Connection.new(@parameters)
|
139
101
|
else
|
140
102
|
@connection = Connection.new(@login, @passcode, @host, @port, @reliable)
|
141
103
|
@connection.autoflush = autoflush
|
142
104
|
end
|
143
|
-
|
144
|
-
start_listeners()
|
145
|
-
|
146
105
|
end
|
106
|
+
private :create_connection
|
147
107
|
|
148
108
|
# open is syntactic sugar for 'Client.new', see 'initialize' for usage.
|
149
109
|
def self.open(login = '', passcode = '', host = 'localhost', port = 61613, reliable = false)
|
data/lib/stomp/version.rb
CHANGED
data/stomp.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{stomp}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian McCallister", "Marius Mathiesen", "Thiago Morello", "Guy M. Allard"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2013-03-28}
|
13
13
|
s.description = %q{Ruby client for the Stomp messaging protocol. Note that this gem is no longer supported on rubyforge.}
|
14
14
|
s.email = ["brianm@apache.org", "marius@stones.com", "morellon@gmail.com", "allard.guy.m@gmail.com"]
|
15
15
|
s.executables = ["catstomp", "stompcat"]
|
data/test/test_connection.rb
CHANGED
@@ -51,11 +51,7 @@ class TestConnection < Test::Unit::TestCase
|
|
51
51
|
@conn.publish make_destination, "test_stomp#test_\000_length",
|
52
52
|
{ :suppress_content_length => true }
|
53
53
|
msg2 = @conn.receive
|
54
|
-
|
55
|
-
assert_equal "test_stomp#test_", msg2.body
|
56
|
-
else
|
57
|
-
assert_equal "test_stomp#test_\000_length", msg2.body
|
58
|
-
end
|
54
|
+
assert_equal "test_stomp#test_", msg2.body
|
59
55
|
checkEmsg(@conn)
|
60
56
|
end unless ENV['STOMP_RABBIT']
|
61
57
|
|
data/test/test_connection1p.rb
CHANGED
@@ -339,7 +339,7 @@ class TestConnection1P < Test::Unit::TestCase
|
|
339
339
|
hb_asserts_both(conn)
|
340
340
|
end if ENV['STOMP_HB11LONG']
|
341
341
|
|
342
|
-
# Test very encoding / decoding of headers
|
342
|
+
# Test very basic encoding / decoding of headers
|
343
343
|
def test_conn_1p_0200
|
344
344
|
@conn.disconnect
|
345
345
|
#
|
@@ -369,6 +369,24 @@ class TestConnection1P < Test::Unit::TestCase
|
|
369
369
|
conn.disconnect
|
370
370
|
end unless ENV['STOMP_RABBIT']
|
371
371
|
|
372
|
+
# Test that 1.1+ connections do not break suppress_content_length
|
373
|
+
# (Issue #52)
|
374
|
+
def test_conn_1p_0210
|
375
|
+
msg = "payload: #{Time.now.to_f}"
|
376
|
+
dest = make_destination
|
377
|
+
shdrs = { :suppress_content_length => true }
|
378
|
+
assert_nothing_raised {
|
379
|
+
@conn.publish dest, msg, shdrs
|
380
|
+
}
|
381
|
+
#
|
382
|
+
sid = @conn.uuid()
|
383
|
+
@conn.subscribe dest, :id => sid
|
384
|
+
#
|
385
|
+
received = @conn.receive
|
386
|
+
assert_equal msg, received.body
|
387
|
+
assert_nil received.headers["content-length"], "No content length expected."
|
388
|
+
end if ENV['STOMP_AMQ11']
|
389
|
+
|
372
390
|
private
|
373
391
|
|
374
392
|
def hb_asserts_both(conn)
|
data/test/test_message.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
# -*- encoding: us-ascii -*-
|
2
|
+
|
1
3
|
#
|
2
4
|
# !!!!
|
3
5
|
#
|
4
6
|
# This can *NOT* currently be marked as UTF-8 encoded. It uses invalid UTF-8
|
5
7
|
# sequences for testing. Tests will fail under 1.9.x+ if this file is marked
|
6
|
-
# as UTF-8 encoded.
|
8
|
+
# as UTF-8 encoded. Tests will fail under 2.0.0 if this file is *NOT* marked
|
9
|
+
# as US-ASCII.
|
7
10
|
#
|
8
11
|
|
9
12
|
if Kernel.respond_to?(:require_relative)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stomp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 9
|
10
|
+
version: 1.2.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian McCallister
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date:
|
21
|
+
date: 2013-03-28 00:00:00 -04:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|