stomp 1.3.5 → 1.4.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.
- data/{CHANGELOG.rdoc → CHANGELOG.md} +57 -40
- data/README.md +708 -0
- data/Rakefile +10 -11
- data/adhoc/.gitignore +7 -0
- data/adhoc/README.md +16 -0
- data/adhoc/issue121_01.rb +129 -0
- data/adhoc/issue121_01_conn.rb +158 -0
- data/adhoc/issue121_02.rb +152 -0
- data/adhoc/issue121_03.rb +157 -0
- data/adhoc/payload_generator.rb +32 -0
- data/adhoc/payload_generator_adhoctest.rb +41 -0
- data/adhoc/stomp_adhoc_common.rb +99 -0
- data/examples/consume_file.rb +63 -0
- data/examples/contrib.sh +6 -0
- data/examples/contributors.rb +106 -0
- data/examples/lflogger.rb +316 -0
- data/examples/publish_file.rb +76 -0
- data/examples/publish_file_conn.rb +75 -0
- data/examples/stomp11_common.rb +7 -1
- data/lib/client/utils.rb +10 -2
- data/lib/connection/heartbeats.rb +1 -0
- data/lib/connection/netio.rb +384 -309
- data/lib/connection/utils.rb +1 -1
- data/lib/stomp/client.rb +30 -23
- data/lib/stomp/connection.rb +28 -23
- data/lib/stomp/constants.rb +4 -0
- data/lib/stomp/errors.rb +9 -0
- data/lib/stomp/version.rb +2 -2
- data/stomp.gemspec +23 -64
- data/test/.gitignore +3 -0
- data/test/test_anonymous.rb +4 -4
- data/test/test_client.rb +14 -11
- data/test/test_connection.rb +4 -4
- data/test/test_connection1p.rb +4 -4
- data/test/test_helper.rb +4 -2
- data/test/test_message.rb +16 -16
- data/test/test_ssl.rb +8 -8
- data/test/test_urlogin.rb +26 -10
- metadata +26 -67
- data/README.rdoc +0 -163
@@ -0,0 +1,75 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'stomp'
|
5
|
+
|
6
|
+
if Kernel.respond_to?(:require_relative)
|
7
|
+
require_relative("./stomp11_common")
|
8
|
+
require_relative("./lflogger")
|
9
|
+
else
|
10
|
+
$LOAD_PATH << File.dirname(__FILE__)
|
11
|
+
require "stomp11_common"
|
12
|
+
require "./lflogger"
|
13
|
+
end
|
14
|
+
include Stomp11Common
|
15
|
+
#
|
16
|
+
# Used primarily for testing performance when sending "large" messages.
|
17
|
+
# "large" => YMMV
|
18
|
+
#
|
19
|
+
class FileSenderConn
|
20
|
+
# Initialize.
|
21
|
+
def initialize
|
22
|
+
end
|
23
|
+
# Run example.
|
24
|
+
def run
|
25
|
+
p [ "pubc001", Thread.current ]
|
26
|
+
publogger = Slogger::new
|
27
|
+
start_time = Time.now.to_f
|
28
|
+
fname = ARGV[0]
|
29
|
+
puts "PUBFC: File Name: #{fname}"
|
30
|
+
file = open(fname, "r")
|
31
|
+
rs = Time.now.to_f
|
32
|
+
buff = file.read
|
33
|
+
re = Time.now.to_f
|
34
|
+
ppt = sprintf("%20.6f", re - rs)
|
35
|
+
puts "PUBFC: File size: #{buff.respond_to?(:bytesize) ? buff.bytesize : buff.length}"
|
36
|
+
puts "PUBFC: File read: #{ppt} seconds"
|
37
|
+
file.close
|
38
|
+
#
|
39
|
+
connection_hdrs = {"accept-version" => "1.1",
|
40
|
+
"host" => virt_host(),
|
41
|
+
}
|
42
|
+
connection_hash = { :hosts => [
|
43
|
+
{:login => login(), :passcode => passcode(),
|
44
|
+
:host => host(), :port => port()},
|
45
|
+
],
|
46
|
+
:connect_headers => connection_hdrs,
|
47
|
+
:logger => publogger,
|
48
|
+
:reliable => false, ### *NOTE*
|
49
|
+
}
|
50
|
+
#
|
51
|
+
# p [ "ch", connection_hash ]
|
52
|
+
connection = Stomp::Connection.new(connection_hash)
|
53
|
+
qname = ENV['STOMP_DEST'] ? ENV['STOMP_DEST'] : "/queue/a.big.file"
|
54
|
+
puts "PUBFC: Qname is: #{qname}"
|
55
|
+
ph = {:presistent => true}
|
56
|
+
ph['suppress_content_length'] = 'yes' if suppresscl()
|
57
|
+
puts "PUBF: Headers are: #{ph.inspect}"
|
58
|
+
# Try to gracefully handle files that exceed broker size limits.
|
59
|
+
begin
|
60
|
+
connection.publish(qname, buff, ph)
|
61
|
+
rescue
|
62
|
+
puts "PUBFC: exception on publish: #{$!}"
|
63
|
+
end
|
64
|
+
e = connection.poll() # Check for unsolicited messages from broker
|
65
|
+
puts "PUBFC: unexpected broker message: #{e}" if e
|
66
|
+
connection.disconnect
|
67
|
+
end_time = Time.now.to_f
|
68
|
+
ppt = sprintf("%20.6f", end_time - start_time)
|
69
|
+
puts "PUBFC: File published: #{ppt} seconds"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
#
|
73
|
+
e = FileSenderConn.new
|
74
|
+
e.run
|
75
|
+
|
data/examples/stomp11_common.rb
CHANGED
@@ -21,7 +21,7 @@ module Stomp11Common
|
|
21
21
|
end
|
22
22
|
# Server port
|
23
23
|
def port()
|
24
|
-
(ENV['STOMP_PORT'] ||
|
24
|
+
(ENV['STOMP_PORT'] || 61613).to_i # !! The author runs AMQ listening here
|
25
25
|
end
|
26
26
|
# Required vhost name
|
27
27
|
def virt_host()
|
@@ -44,5 +44,11 @@ module Stomp11Common
|
|
44
44
|
def nmsgs()
|
45
45
|
(ENV['STOMP_NMSGS'] || 1).to_i # Number of messages
|
46
46
|
end
|
47
|
+
|
48
|
+
# Include "suppress-content-length' header
|
49
|
+
def suppresscl()
|
50
|
+
ENV['STOMP_SUPPRESS_CL']
|
51
|
+
end
|
52
|
+
|
47
53
|
end
|
48
54
|
|
data/lib/client/utils.rb
CHANGED
@@ -20,8 +20,11 @@ module Stomp
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def parse_stomp_url(login)
|
23
|
+
original_verbose, $VERBOSE = $VERBOSE, nil # shut off warnings
|
23
24
|
regexp = /^stomp:\/\/#{URL_REPAT}/
|
24
|
-
|
25
|
+
url = regexp.match(login)
|
26
|
+
$VERBOSE = original_verbose
|
27
|
+
return false unless url
|
25
28
|
|
26
29
|
@parameters = { :reliable => false,
|
27
30
|
:hosts => [ { :login => url[3] || "",
|
@@ -34,7 +37,10 @@ module Stomp
|
|
34
37
|
# e.g. failover://(stomp://login1:passcode1@localhost:61616,stomp://login2:passcode2@remotehost:61617)?option1=param
|
35
38
|
def parse_failover_url(login)
|
36
39
|
rval = nil
|
37
|
-
|
40
|
+
original_verbose, $VERBOSE = $VERBOSE, nil # shut off warnings
|
41
|
+
md = FAILOVER_REGEX.match(login)
|
42
|
+
$VERBOSE = original_verbose
|
43
|
+
if md
|
38
44
|
finhosts = parse_hosts(login)
|
39
45
|
|
40
46
|
options = {}
|
@@ -75,6 +81,7 @@ module Stomp
|
|
75
81
|
# Parse a stomp URL.
|
76
82
|
def parse_hosts(url)
|
77
83
|
hosts = []
|
84
|
+
original_verbose, $VERBOSE = $VERBOSE, nil # shut off warnings
|
78
85
|
host_match = /stomp(\+ssl)?:\/\/#{URL_REPAT}/
|
79
86
|
url.scan(host_match).each do |match|
|
80
87
|
host = {}
|
@@ -85,6 +92,7 @@ module Stomp
|
|
85
92
|
host[:port] = match[6].to_i
|
86
93
|
hosts << host
|
87
94
|
end
|
95
|
+
$VERBOSE = original_verbose
|
88
96
|
hosts
|
89
97
|
end
|
90
98
|
|