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/Rakefile CHANGED
@@ -19,10 +19,12 @@ require 'rspec/core/rake_task'
19
19
  require "stomp/version"
20
20
 
21
21
  begin
22
- require "hanna/rdoctask"
22
+ require "hanna-nouveau"
23
+ have_hanna = true
23
24
  rescue LoadError => e
24
- require "rdoc/task"
25
+ have_hanna = false
25
26
  end
27
+ require "rdoc/task"
26
28
 
27
29
  begin
28
30
  require 'jeweler'
@@ -30,7 +32,7 @@ begin
30
32
  gem.name = "stomp"
31
33
  gem.version = Stomp::Version::STRING
32
34
  gem.summary = %Q{Ruby client for the Stomp messaging protocol}
33
- gem.license = "Apache 2.0"
35
+ gem.license = "Apache-2.0"
34
36
  gem.description = %Q{Ruby client for the Stomp messaging protocol. Note that this gem is no longer supported on rubyforge.}
35
37
  gem.email = ["brianm@apache.org", 'marius@stones.com', 'morellon@gmail.com',
36
38
  'allard.guy.m@gmail.com' ]
@@ -38,9 +40,6 @@ begin
38
40
  gem.authors = ["Brian McCallister", 'Marius Mathiesen', 'Thiago Morello',
39
41
  'Guy M. Allard']
40
42
  gem.add_development_dependency "rspec", '>= 2.14.1'
41
- gem.extra_rdoc_files = [ "README.rdoc", "CHANGELOG.rdoc", "LICENSE",
42
- "lib/**/*.rb", "examples/**/*.rb",
43
- "test/**/*.rb" ]
44
43
  end
45
44
  Jeweler::GemcutterTasks.new
46
45
  rescue LoadError
@@ -61,12 +60,14 @@ RSpec::Core::RakeTask.new('spec:rcov') do |t|
61
60
  end
62
61
 
63
62
  Rake::RDocTask.new do |rdoc|
64
- rdoc.main = "README.rdoc"
63
+ rdoc.main = "README.md"
65
64
  rdoc.rdoc_dir = "doc"
66
65
  rdoc.title = "Stomp"
67
66
  rdoc.options += %w[ --line-numbers --inline-source --charset utf-8 ]
68
- rdoc.rdoc_files.include("README.rdoc", "CHANGELOG.rdoc", "lib/**/*.rb", "examples/**/*.rb",
69
- "test/**/*.rb")
67
+ if have_hanna
68
+ rdoc.options += %w[ --format hanna ]
69
+ end
70
+ rdoc.rdoc_files.include("README.md", "CHANGELOG.md", "lib/**/*.rb")
70
71
  end
71
72
 
72
73
  Rake::TestTask.new do |t|
@@ -77,5 +78,3 @@ end
77
78
 
78
79
  task :default => :spec
79
80
 
80
-
81
-
data/adhoc/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ # No html in this directory
2
+ *.html
3
+ *.htm
4
+ # Typical backup files
5
+ *~
6
+ *.bak
7
+
data/adhoc/README.md ADDED
@@ -0,0 +1,16 @@
1
+ <link href="http://kevinburke.bitbucket.org/markdowncss/markdown.css" rel="stylesheet"></link>
2
+
3
+ # The Ruby stomp Gem - Adhoc Items #
4
+
5
+ This directory will contain a variety of artifacts.
6
+
7
+ It is envisioned that content will mostly be of interest to gem developers.
8
+ However gem clients may find items of interest here as well.
9
+
10
+ ## Issue 121 ##
11
+
12
+ Much of the initial work in this directory has focused on
13
+ recreating / confirming the high memory use described in
14
+ [issue 121](https://github.com/stompgem/stomp/issues/121).
15
+
16
+ Resolution of that issue is TDB (2016.05.25).
@@ -0,0 +1,129 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'stomp'
4
+
5
+ # Focus on this gem's capabilities.
6
+ # require 'memory_profiler'
7
+ require 'memory-profiler'
8
+
9
+ if Kernel.respond_to?(:require_relative)
10
+ require_relative("stomp_adhoc_common")
11
+ else
12
+ $LOAD_PATH << File.dirname(__FILE__)
13
+ require "stomp_adhoc_common"
14
+ end
15
+ include Stomp11Common
16
+
17
+ # Initial testing around issue #121.
18
+
19
+ class Issue121Examp01
20
+
21
+ attr_reader :client, :session
22
+
23
+ # Initialize.
24
+ def initialize(topic = false)
25
+ @client, @session, @topic = nil, nil, topic
26
+ @nmsgs = nmsgs()
27
+ @queue = make_destination("issue121/test_01")
28
+ @id = "issue121_01"
29
+ @block = cli_block()
30
+ end # initialize
31
+
32
+ # Startup
33
+ def start
34
+ #
35
+ client_hdrs = {"accept-version" => "1.1,1.2",
36
+ "host" => virt_host,
37
+ }
38
+ #
39
+ client_hash = { :hosts => [
40
+ {:login => login(), :passcode => passcode(), :host => host(), :port => port()},
41
+ ],
42
+ :connect_headers => client_hdrs,
43
+ }
44
+ #
45
+ @client = Stomp::Client.new(client_hash)
46
+ puts "START: Client Connect complete"
47
+ raise "START: Connection failed!!" unless @client.open?
48
+ raise "START: Unexpected protocol level!!" if @client.protocol() == Stomp::SPL_10
49
+ cf = @client.connection_frame()
50
+ puts "START: Connection frame\n#{cf}"
51
+ raise "START: Connect error!!: #{cf.body}" if @client.connection_frame().command == Stomp::CMD_ERROR
52
+ @session = @client.connection_frame().headers['session']
53
+ puts "START: Queue/Topic Name: #{@queue}"
54
+ puts "START: Session: #{@session}"
55
+ puts "START: Block: #{@block}"
56
+ $stdout.flush
57
+ end # start
58
+
59
+ #
60
+ def shutdown
61
+ @client.close
62
+ puts "SHUT: Shutdown complete"
63
+ end # shutdown
64
+
65
+ # pub
66
+ def publish
67
+ m = "Message: "
68
+ nm = 0
69
+ @nmsgs.times do |n|
70
+ nm += 1
71
+ puts "PUB: NEXT MESSAGE NUMBER: #{nm}"
72
+ mo = "#{m} #{n}"
73
+ puts "PUB: PAYLOAD: #{mo}"
74
+ hs = {:session => @session}
75
+ if @block
76
+ ip = false
77
+ @client.publish(@queue,
78
+ mo,
79
+ hs) {|m|
80
+ puts "PUB: HAVE_RECEIPT:\nID: #{m.headers['receipt-id']}"
81
+ ip = m
82
+ }
83
+ sleep 0.01 until ip
84
+ else
85
+ @client.publish(@queue, mo, hs)
86
+ end # if @block
87
+
88
+ end # @nmsgs.times do
89
+
90
+ end # publish
91
+
92
+ # sub
93
+ def subscribe
94
+ puts "SUB: Subscribe starts For: #{@queue}"
95
+ rmc, done = 0, false
96
+ sh = {:id => "#{@id}", :ack => "auto"}
97
+ @client.subscribe(@queue, sh) {|m|
98
+ rmc += 1
99
+ rm = m
100
+ puts "SUB: HAVE_MESSAGE:\n#{rm}"
101
+ if rmc >= @nmsgs
102
+ puts "SUB: Subscribe is ending for #{@queue}"
103
+ done = true
104
+ Thread.done
105
+ end
106
+ }
107
+ sleep 0.01 until done
108
+ puts "SUB: Receives Done For: #{@queue}"
109
+ end # subscribe
110
+
111
+ end # class
112
+
113
+ #
114
+ # puts "BEG: Memory Profiler Version is: #{MemoryProfiler::VERSION}"
115
+ MemoryProfiler::start_daemon( :limit=>5, :delay=>10, :marshal_size=>true, :sort_by=>:absdelta )
116
+ #
117
+ 5.times do |i|
118
+ rpt = MemoryProfiler.start( :limit=>10 ) do
119
+ e = Issue121Examp01.new
120
+ e.start
121
+ e.publish
122
+ e.subscribe
123
+ e.shutdown
124
+ end
125
+ puts MemoryProfiler.format(rpt)
126
+ sleep 1
127
+ end
128
+ #
129
+ MemoryProfiler::stop_daemon
@@ -0,0 +1,158 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'stomp'
4
+ require 'tmpdir'
5
+
6
+ # Focus on this gem's capabilities.
7
+ require 'memory_profiler'
8
+ # require 'memory-profiler'
9
+
10
+ if Kernel.respond_to?(:require_relative)
11
+ require_relative("stomp_adhoc_common")
12
+ require_relative("payload_generator")
13
+ else
14
+ $LOAD_PATH << File.dirname(__FILE__)
15
+ require "stomp_adhoc_common"
16
+ require("payload_generator")
17
+ end
18
+ include Stomp11Common
19
+
20
+ # Next of testing around issue #121.
21
+ # Different memory profiler gem.
22
+ # Use Stomp#connection to merely send
23
+
24
+ class Issue121Examp01Conn
25
+
26
+ attr_reader :connection, :session
27
+
28
+ # Initialize.
29
+ def initialize(topic = false)
30
+ @connection, @session, @topic = nil, nil, topic
31
+ @nmsgs = nmsgs()
32
+ @queue = make_destination("issue121/test_01_conn")
33
+ @id = "issue121_01_conn"
34
+ @getreceipt = conn_receipt()
35
+ #
36
+ @cmin, @cmax = 1292, 67782 # From the issue discussion
37
+ PayloadGenerator::initialize(min= @cmin, max= @cmax)
38
+ @ffmts = "%16.6f"
39
+ #
40
+ mps = 5.6 # see issue discussion
41
+ @to, @nmts, @nts, @umps = 0.0, Time.now.to_f, @nmsgs, mps
42
+ @tslt = 1.0 / @umps
43
+ end # initialize
44
+
45
+ # Startup
46
+ def start
47
+ #
48
+ connect_hdrs = {"accept-version" => "1.1,1.2",
49
+ "host" => virt_host,
50
+ }
51
+ #
52
+ connect_hash = { :hosts => [
53
+ {:login => login(), :passcode => passcode(), :host => host(), :port => port()},
54
+ ],
55
+ :connect_headers => connect_hdrs,
56
+ }
57
+ #
58
+ @connection = Stomp::Connection.new(connect_hash)
59
+ puts "START: Connection Connect complete"
60
+ raise "START: Connection failed!!" unless @connection.open?
61
+ raise "START: Unexpected protocol level!!" if @connection.protocol == Stomp::SPL_10
62
+ cf = @connection.connection_frame
63
+ puts "START: Connection frame\n#{cf}"
64
+ raise "START: Connect error!!: #{cf.body}" if @connection.connection_frame.command == Stomp::CMD_ERROR
65
+ @session = @connection.connection_frame.headers['session']
66
+ puts "START: Queue/Topic Name: #{@queue}"
67
+ puts "START: Session: #{@session}"
68
+ puts "START: NMSGS: #{@nmsgs}"
69
+ puts "START: Receipt: #{@getreceipt}"
70
+ puts "START: Wanted Messages Per Second: #{@umps}"
71
+ puts "START: Sleep Time: #{@tslt}"
72
+ $stdout.flush
73
+ end # start
74
+
75
+ #
76
+ def shutdown
77
+ @connection.disconnect()
78
+ #
79
+ te = Time.now.to_f
80
+ et = te - @nmts
81
+ avgsz = @to / @nts
82
+ mps = @nts.to_f / et
83
+ #
84
+ fet = sprintf(@ffmts, et)
85
+ favgsz = sprintf(@ffmts, avgsz)
86
+ fmps = sprintf(@ffmts, mps)
87
+ #
88
+ sep = "=" * 72
89
+ puts sep
90
+ puts "\tNumber of payloads generated: #{@nts}"
91
+ puts "\tMin Length: #{@cmin}, Max Length: #{@cmax}"
92
+ puts "\tAVG_SIZE: #{favgsz}, ELAPS_SEC: #{fet}(seconds)"
93
+ puts "\tNMSGS_PER_SEC: #{fmps}"
94
+ puts sep
95
+ #
96
+ puts "SHUT: Shutdown complete"
97
+ $stdout.flush
98
+ end # shutdown
99
+
100
+ #
101
+ def msg_handler
102
+ m = "Message: "
103
+ nm = 0
104
+
105
+ @nmsgs.times do |n|
106
+ nm += 1
107
+ puts "MSH: NEXT MESSAGE NUMBER: #{nm}"; $stdout.flush
108
+ mo = PayloadGenerator::payload()
109
+ @to += mo.bytesize()
110
+
111
+ if @getreceipt
112
+ uuid = @connection.uuid()
113
+ puts "MSH: Receipt id wanted is #{uuid}"
114
+ hs = {:session => @session, :receipt => uuid}
115
+ else
116
+ hs = {:session => @session}
117
+ end
118
+
119
+ # Move data out the door
120
+ @connection.publish(@queue, mo, hs)
121
+
122
+ if @getreceipt
123
+ r = @connection.receive()
124
+ puts "MSH: received receipt, id is #{r.headers['receipt-id']}"
125
+ raise if uuid != r.headers['receipt-id']
126
+ end
127
+ #
128
+ puts "MSH: start user sleep"
129
+ sleep @tslt # see issue discussion
130
+ puts "MSH: end user sleep"
131
+ $stdout.flush
132
+ end # @nmsgs.times do
133
+
134
+ puts "MSH: end of msg_handler"
135
+ $stdout.flush
136
+ end # msg_handler
137
+
138
+ end # class
139
+
140
+ #
141
+ 1.times do |i|
142
+ rpt = MemoryProfiler.report do
143
+ e = Issue121Examp01Conn.new
144
+ e.start
145
+ e.msg_handler
146
+ # No subscribes here, just msg_handler
147
+ # See discussion in issue #121
148
+ e.shutdown
149
+ end
150
+ n = Time.now
151
+ nf = "memory_profiler-ng"
152
+ nf << n.strftime("%Y%m%dT%H%M%S.%N%Z")
153
+ where_name = File::join(Dir::tmpdir(), nf)
154
+ rpt.pretty_print(to_file: where_name )
155
+ # sleep 1
156
+ end
157
+ #
158
+
@@ -0,0 +1,152 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'stomp'
4
+
5
+ # Focus on this gem's capabilities.
6
+ # require 'memory_profiler'
7
+ require 'memory-profiler'
8
+
9
+ if Kernel.respond_to?(:require_relative)
10
+ require_relative("stomp_adhoc_common")
11
+ require_relative("payload_generator")
12
+ else
13
+ $LOAD_PATH << File.dirname(__FILE__)
14
+ require "stomp_adhoc_common"
15
+ require("payload_generator")
16
+ end
17
+ include Stomp11Common
18
+
19
+ # Round 2 of testing around issue #121.
20
+
21
+ class Issue121Examp02
22
+
23
+ attr_reader :client, :session
24
+
25
+ # Initialize.
26
+ def initialize(topic = false)
27
+ @client, @session, @topic = nil, nil, topic
28
+ @nmsgs = nmsgs()
29
+ @queue = make_destination("issue121/test_02")
30
+ @id = "issue121_02"
31
+ @block = cli_block()
32
+ #
33
+ @cmin, @cmax = 1292, 67782 # From the issue discussion
34
+ PayloadGenerator::initialize(min= @cmin, max= @cmax)
35
+ @ffmts = "%16.6f"
36
+ #
37
+ mps = 5.6 # see issue discussion
38
+ @to, @nmts, @nts, @umps = 0.0, Time.now.to_f, @nmsgs, mps
39
+ @tslt = 1.0 / @umps
40
+ end # initialize
41
+
42
+ # Startup
43
+ def start
44
+ #
45
+ client_hdrs = {"accept-version" => "1.1,1.2",
46
+ "host" => virt_host,
47
+ }
48
+ #
49
+ client_hash = { :hosts => [
50
+ {:login => login(), :passcode => passcode(), :host => host(), :port => port()},
51
+ ],
52
+ :connect_headers => client_hdrs,
53
+ }
54
+ #
55
+ @client = Stomp::Client.new(client_hash)
56
+ puts "START: Client Connect complete"
57
+ raise "START: Connection failed!!" unless @client.open?
58
+ raise "START: Unexpected protocol level!!" if @client.protocol() == Stomp::SPL_10
59
+ cf = @client.connection_frame()
60
+ puts "START: Connection frame\n#{cf}"
61
+ raise "START: Connect error!!: #{cf.body}" if @client.connection_frame().command == Stomp::CMD_ERROR
62
+ @session = @client.connection_frame().headers['session']
63
+ puts "START: Queue/Topic Name: #{@queue}"
64
+ puts "START: Session: #{@session}"
65
+ puts "START: NMSGS: #{@nmsgs}"
66
+ puts "START: Block: #{@block}"
67
+ puts "START: Wanted Messages Per Second: #{@umps}"
68
+ puts "START: Sleep Time: #{@tslt}"
69
+ $stdout.flush
70
+ end # start
71
+
72
+ #
73
+ def shutdown
74
+ @client.close
75
+ #
76
+ te = Time.now.to_f
77
+ et = te - @nmts
78
+ avgsz = @to / @nts
79
+ mps = @nts.to_f / et
80
+ #
81
+ fet = sprintf(@ffmts, et)
82
+ favgsz = sprintf(@ffmts, avgsz)
83
+ fmps = sprintf(@ffmts, mps)
84
+ #
85
+ sep = "=" * 72
86
+ puts sep
87
+ puts "\tNumber of payloads generated: #{@nts}"
88
+ puts "\tMin Length: #{@cmin}, Max Length: #{@cmax}"
89
+ puts "\tAVG_SIZE: #{favgsz}, ELAPS_SEC: #{fet}(seconds)"
90
+ puts "\tNMSGS_PER_SEC: #{fmps}"
91
+ puts sep
92
+ #
93
+ puts "SHUT: Shutdown complete"
94
+ $stdout.flush
95
+ end # shutdown
96
+
97
+ # pub
98
+ def publish
99
+ m = "Message: "
100
+ nm = 0
101
+
102
+ @nmsgs.times do |n|
103
+ nm += 1
104
+ puts "PUB: NEXT MESSAGE NUMBER: #{nm}"; $stdout.flush
105
+ mo = PayloadGenerator::payload()
106
+ @to += mo.bytesize()
107
+ hs = {:session => @session}
108
+
109
+ if @block
110
+ ip = false
111
+ @client.publish(@queue,
112
+ mo,
113
+ hs) {|m|
114
+ puts "PUB: HAVE_RECEIPT:\nID: #{m.headers['receipt-id']}"
115
+ $stdout.flush
116
+ ip = m
117
+ }
118
+ sleep 0.01 until ip
119
+ else
120
+ @client.publish(@queue, mo, hs)
121
+ end # if @block
122
+
123
+ puts "PUB: start user sleep"
124
+ sleep @tslt # see issue discussion
125
+ puts "PUB: end user sleep"
126
+ $stdout.flush
127
+ end # @nmsgs.times do
128
+
129
+ puts "PUB: end of publish"
130
+ $stdout.flush
131
+ end # publish
132
+
133
+ end # class
134
+
135
+ #
136
+ # :limit => is max number of classes to report on
137
+ MemoryProfiler::start_daemon( :limit=>25, :delay=>10, :marshal_size=>true, :sort_by=>:absdelta )
138
+ #
139
+ 1.times do |i|
140
+ rpt = MemoryProfiler.start( :limit=> 25 ) do
141
+ e = Issue121Examp02.new
142
+ e.start
143
+ e.publish
144
+ # No subscribes here, just publish
145
+ # See discussion in issue #121
146
+ e.shutdown
147
+ end
148
+ puts MemoryProfiler.format(rpt)
149
+ sleep 1
150
+ end
151
+ #
152
+ MemoryProfiler::stop_daemon
@@ -0,0 +1,157 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'stomp'
4
+ require 'tmpdir'
5
+
6
+ # Focus on this gem's capabilities.
7
+ require 'memory_profiler'
8
+ # require 'memory-profiler'
9
+
10
+ if Kernel.respond_to?(:require_relative)
11
+ require_relative("stomp_adhoc_common")
12
+ require_relative("payload_generator")
13
+ else
14
+ $LOAD_PATH << File.dirname(__FILE__)
15
+ require "stomp_adhoc_common"
16
+ require("payload_generator")
17
+ end
18
+ include Stomp11Common
19
+
20
+ # Round 3 of testing around issue #121.
21
+ # Different memory profiler gem.
22
+
23
+ class Issue121Examp03
24
+
25
+ attr_reader :client, :session
26
+
27
+ # Initialize.
28
+ def initialize(topic = false)
29
+ @client, @session, @topic = nil, nil, topic
30
+ @nmsgs = nmsgs()
31
+ @queue = make_destination("issue121/test_03")
32
+ @id = "issue121_03"
33
+ @block = cli_block()
34
+ #
35
+ @cmin, @cmax = 1292, 67782 # From the issue discussion
36
+ PayloadGenerator::initialize(min= @cmin, max= @cmax)
37
+ @ffmts = "%16.6f"
38
+ #
39
+ mps = 5.6 # see issue discussion
40
+ @to, @nmts, @nts, @umps = 0.0, Time.now.to_f, @nmsgs, mps
41
+ @tslt = 1.0 / @umps
42
+ end # initialize
43
+
44
+ # Startup
45
+ def start
46
+ #
47
+ client_hdrs = {"accept-version" => "1.1,1.2",
48
+ "host" => virt_host,
49
+ }
50
+ #
51
+ client_hash = { :hosts => [
52
+ {:login => login(), :passcode => passcode(), :host => host(), :port => port()},
53
+ ],
54
+ :connect_headers => client_hdrs,
55
+ }
56
+ #
57
+ @client = Stomp::Client.new(client_hash)
58
+ puts "START: Client Connect complete"
59
+ raise "START: Connection failed!!" unless @client.open?
60
+ raise "START: Unexpected protocol level!!" if @client.protocol() == Stomp::SPL_10
61
+ cf = @client.connection_frame()
62
+ puts "START: Connection frame\n#{cf}"
63
+ raise "START: Connect error!!: #{cf.body}" if @client.connection_frame().command == Stomp::CMD_ERROR
64
+ @session = @client.connection_frame().headers['session']
65
+ puts "START: Queue/Topic Name: #{@queue}"
66
+ puts "START: Session: #{@session}"
67
+ puts "START: NMSGS: #{@nmsgs}"
68
+ puts "START: Block: #{@block}"
69
+ puts "START: Wanted Messages Per Second: #{@umps}"
70
+ puts "START: Sleep Time: #{@tslt}"
71
+ $stdout.flush
72
+ end # start
73
+
74
+ #
75
+ def shutdown
76
+ @client.close
77
+ #
78
+ te = Time.now.to_f
79
+ et = te - @nmts
80
+ avgsz = @to / @nts
81
+ mps = @nts.to_f / et
82
+ #
83
+ fet = sprintf(@ffmts, et)
84
+ favgsz = sprintf(@ffmts, avgsz)
85
+ fmps = sprintf(@ffmts, mps)
86
+ #
87
+ sep = "=" * 72
88
+ puts sep
89
+ puts "\tNumber of payloads generated: #{@nts}"
90
+ puts "\tMin Length: #{@cmin}, Max Length: #{@cmax}"
91
+ puts "\tAVG_SIZE: #{favgsz}, ELAPS_SEC: #{fet}(seconds)"
92
+ puts "\tNMSGS_PER_SEC: #{fmps}"
93
+ puts sep
94
+ #
95
+ puts "SHUT: Shutdown complete"
96
+ $stdout.flush
97
+ end # shutdown
98
+
99
+ # pub
100
+ def publish
101
+ m = "Message: "
102
+ nm = 0
103
+
104
+ @nmsgs.times do |n|
105
+ nm += 1
106
+ puts "PUB: NEXT MESSAGE NUMBER: #{nm}"; $stdout.flush
107
+ mo = PayloadGenerator::payload()
108
+ @to += mo.bytesize()
109
+ hs = {:session => @session}
110
+
111
+ if @block
112
+ ip = false
113
+ @client.publish(@queue,
114
+ mo,
115
+ hs) {|m|
116
+ puts "PUB: HAVE_RECEIPT:\nID: #{m.headers['receipt-id']}"
117
+ $stdout.flush
118
+ ip = m
119
+ }
120
+ sleep 0.01 until ip
121
+ else
122
+ @client.publish(@queue, mo, hs)
123
+ end # if @block
124
+
125
+ if nm < @nmsgs
126
+ puts "PUB: start user sleep"
127
+ sleep @tslt # see issue discussion
128
+ puts "PUB: end user sleep"
129
+ end
130
+ $stdout.flush
131
+ end # @nmsgs.times do
132
+
133
+ puts "PUB: end of publish"
134
+ $stdout.flush
135
+ end # publish
136
+
137
+ end # class
138
+
139
+ #
140
+ 1.times do |i|
141
+ rpt = MemoryProfiler.report do
142
+ e = Issue121Examp03.new
143
+ e.start
144
+ e.publish
145
+ # No subscribes here, just publish
146
+ # See discussion in issue #121
147
+ e.shutdown
148
+ end
149
+ n = Time.now
150
+ nf = "memory_profiler-ng"
151
+ nf << n.strftime("%Y%m%dT%H%M%S.%N%Z")
152
+ where_name = File::join(Dir::tmpdir(), nf)
153
+ rpt.pretty_print(to_file: where_name )
154
+ # sleep 1
155
+ end
156
+ #
157
+
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ class PayloadGenerator
4
+
5
+ private
6
+
7
+ @@BSTRING = ""
8
+
9
+ public
10
+
11
+ def self.initialize(min = 1, max = 4096)
12
+ srand()
13
+ #
14
+ @@min, @@max = min, max
15
+ if @@min > @@max
16
+ @@min, @@max = @@max, @@min
17
+ warn "Swapping min and max values"
18
+ end
19
+ #
20
+ @@BSTRING = "9" * @@max
21
+ nil
22
+ end # of initialize
23
+
24
+ def self.payload
25
+ i = rand(@@max - @@min)
26
+ i = 1 if i == 0
27
+ i += @@min
28
+ # puts "DBI: #{i}"
29
+ @@BSTRING.byteslice(0, i)
30
+ end
31
+
32
+ end # of class