stomp 1.4.5 → 1.4.10

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -33,7 +33,7 @@ begin
33
33
  gem.version = Stomp::Version::STRING
34
34
  gem.summary = %Q{Ruby client for the Stomp messaging protocol}
35
35
  gem.license = "Apache-2.0"
36
- gem.description = %Q{Ruby client for the Stomp messaging protocol. Note that this gem is no longer supported on rubyforge.}
36
+ gem.description = %Q{Ruby client for the Stomp messaging protocol.}
37
37
  gem.email = ["brianm@apache.org", 'marius@stones.com', 'morellon@gmail.com',
38
38
  'allard.guy.m@gmail.com' ]
39
39
  gem.homepage = "https://github.com/stompgem/stomp"
@@ -0,0 +1,122 @@
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("./stomp_common")
9
+ else
10
+ $LOAD_PATH << File.dirname(__FILE__)
11
+ require "stomp_common"
12
+ end
13
+ include Stomp1xCommon
14
+
15
+ #
16
+ # == Stomp 1.x Putt / Get Example
17
+ #
18
+ # Purpose: to demonstrate producing and consuming messages using a
19
+ # Stomp#Connection instance.
20
+ #
21
+ # Note: this example assumes that you have at least the 1.2.0 gem release
22
+ # installed.
23
+ #
24
+ # When you:
25
+ #
26
+ # * Use a Stomp compliant broker
27
+ # * Want a Stomp 1.1+ connection and functionality
28
+ #
29
+ # then your code *must* specifically request that environment.
30
+ #
31
+ # You need to supply all of the normal values expected of course:
32
+ #
33
+ # * login - the user name
34
+ # * passcode - the password
35
+ # * host - the host to connect to
36
+ # * port - the port to connect to
37
+ #
38
+ # Additionaly you are required to supply the 1.1+ connection data as documented
39
+ # in the Stomp 1.1+ specifications:
40
+ #
41
+ # http://stomp.github.com/stomp-specification-1.0.html
42
+ # http://stomp.github.com/stomp-specification-1.1.html
43
+ # http://stomp.github.com/stomp-specification-1.2.html
44
+ #
45
+ # You are urged to become familiar with the specs. They are short documents.
46
+ #
47
+ # This includes:
48
+ #
49
+ # * The Stomp version(s) you wish the broker to consider
50
+ # * The broker vhost to connect to
51
+ #
52
+ # You may optionally specify other 1.1+ data:
53
+ #
54
+ # * heartbeat request
55
+ #
56
+ # Using the stomp gem, you should specify this data in the "connect_headers" Hash
57
+ # parameter. This example uses the common get_connection() method to
58
+ # get a connection.
59
+ #
60
+ class ConnectionGetExample
61
+ # Initialize
62
+ def initialize
63
+ end
64
+ # Run example
65
+ def run
66
+ #
67
+ # Get a connection
68
+ # ================
69
+ #
70
+ conn = get_connection()
71
+ #
72
+ # Let's just do some sanity checks, and look around.
73
+ #
74
+ raise "Connection failed!!" unless conn.open?()
75
+ #
76
+ # The broker _could_ have returned an ERROR frame (unlikely).
77
+ #
78
+ raise "Connect error: #{conn.connection_frame.body}" if conn.connection_frame.command == Stomp::CMD_ERROR
79
+ #
80
+ puts "Connection complete."
81
+ #
82
+ # Get Destination
83
+ #
84
+ qname = dest()
85
+ nm = nmsgs()
86
+ puts
87
+ puts "Connection start receives"
88
+ #
89
+ # Receives
90
+ #
91
+ # Subscribe
92
+ #
93
+ uuid = conn.uuid() # uuid for Stomp::Connection is a public method
94
+ conn.subscribe(qname, {'id' => uuid}) # Subscribe
95
+ #
96
+ # Run gets
97
+ #
98
+ received = ""
99
+ 1.upto(nm) do
100
+ received = conn.receive()
101
+ puts "Received headers: #{received.headers}"
102
+ puts "Received body: #{received.body}"
103
+ end
104
+ puts
105
+ received.headers.each do |h|
106
+ puts h
107
+ end
108
+ #
109
+ # And be polite, unsubscribe.
110
+ #
111
+ conn.unsubscribe(qname, {'id' => uuid})
112
+ #
113
+ # Finally disconnect
114
+ # ==================
115
+ #
116
+ conn.disconnect() # Business as usual
117
+ puts "\nConnection disconnect complete"
118
+ end
119
+ end
120
+ #
121
+ e = ConnectionGetExample.new()
122
+ e.run
@@ -0,0 +1,111 @@
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("./stomp_common")
9
+ else
10
+ $LOAD_PATH << File.dirname(__FILE__)
11
+ require "stomp_common"
12
+ end
13
+ include Stomp1xCommon
14
+
15
+ #
16
+ # == Stomp 1.x Putt / Get Example
17
+ #
18
+ # Purpose: to demonstrate producing and consuming messages using a
19
+ # Stomp#Connection instance.
20
+ #
21
+ # Note: this example assumes that you have at least the 1.2.0 gem release
22
+ # installed.
23
+ #
24
+ # When you:
25
+ #
26
+ # * Use a Stomp compliant broker
27
+ # * Want a Stomp 1.1+ connection and functionality
28
+ #
29
+ # then your code *must* specifically request that environment.
30
+ #
31
+ # You need to supply all of the normal values expected of course:
32
+ #
33
+ # * login - the user name
34
+ # * passcode - the password
35
+ # * host - the host to connect to
36
+ # * port - the port to connect to
37
+ #
38
+ # Additionaly you are required to supply the 1.1+ connection data as documented
39
+ # in the Stomp 1.1+ specifications:
40
+ #
41
+ # http://stomp.github.com/stomp-specification-1.0.html
42
+ # http://stomp.github.com/stomp-specification-1.1.html
43
+ # http://stomp.github.com/stomp-specification-1.2.html
44
+ #
45
+ # You are urged to become familiar with the specs. They are short documents.
46
+ #
47
+ # This includes:
48
+ #
49
+ # * The Stomp version(s) you wish the broker to consider
50
+ # * The broker vhost to connect to
51
+ #
52
+ # You may optionally specify other 1.1+ data:
53
+ #
54
+ # * heartbeat request
55
+ #
56
+ # Using the stomp gem, you should specify this data in the "connect_headers" Hash
57
+ # parameter. This example uses the common get_connection() method to
58
+ # get a connection.
59
+ #
60
+ class ConnectionPutExample
61
+ # Initialize
62
+ def initialize
63
+ end
64
+ # Run example
65
+ def run
66
+ #
67
+ # Get a connection
68
+ # ================
69
+ #
70
+ conn = get_connection()
71
+ #
72
+ # Let's just do some sanity checks, and look around.
73
+ #
74
+ raise "Connection failed!!" unless conn.open?()
75
+ #
76
+ # The broker _could_ have returned an ERROR frame (unlikely).
77
+ #
78
+ raise "Connect error: #{conn.connection_frame.body}" if conn.connection_frame.command == Stomp::CMD_ERROR
79
+ #
80
+ puts "Connection complete."
81
+ #
82
+ # Get Destination
83
+ #
84
+ qname = dest()
85
+ #
86
+ # Publish/put messages
87
+ #
88
+ puts "\nConnection start puts"
89
+ nm = nmsgs()
90
+ ph = {:persistent => true}
91
+ ph['suppress_content_length'] = 'yes' if suppresscl()
92
+ ph['K:A'] = 'V:A'
93
+ ph['K\B'] = 'V\B'
94
+ ph['K:C'] = 'V\C'
95
+ puts "Put Headers: #{ph}"
96
+ 1.upto(nm) do |n|
97
+ data = "message payload: #{n} #{Time.now.to_f}"
98
+ conn.publish(qname, data, ph)
99
+ puts "Sent: #{data}"
100
+ end
101
+ #
102
+ # Finally disconnect
103
+ # ==================
104
+ #
105
+ conn.disconnect() # Business as usual
106
+ puts "\nConnection disconnect complete"
107
+ end
108
+ end
109
+ #
110
+ e = ConnectionPutExample.new()
111
+ e.run
@@ -0,0 +1,117 @@
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("./stomp_common")
9
+ else
10
+ $LOAD_PATH << File.dirname(__FILE__)
11
+ require "stomp_common"
12
+ end
13
+ include Stomp1xCommon
14
+
15
+ #
16
+ # == Stomp 1.x Putt / Get Example
17
+ #
18
+ # Purpose: to demonstrate producing and consuming messages using a
19
+ # Stomp#Connection instance.
20
+ #
21
+ # Note: this example assumes that you have at least the 1.2.0 gem release
22
+ # installed.
23
+ #
24
+ # When you:
25
+ #
26
+ # * Use a Stomp compliant broker
27
+ # * Want a Stomp 1.1+ connection and functionality
28
+ #
29
+ # then your code *must* specifically request that environment.
30
+ #
31
+ # You need to supply all of the normal values expected of course:
32
+ #
33
+ # * login - the user name
34
+ # * passcode - the password
35
+ # * host - the host to connect to
36
+ # * port - the port to connect to
37
+ #
38
+ # Additionaly you are required to supply the 1.1+ connection data as documented
39
+ # in the Stomp 1.1+ specifications:
40
+ #
41
+ # http://stomp.github.com/stomp-specification-1.0.html
42
+ # http://stomp.github.com/stomp-specification-1.1.html
43
+ # http://stomp.github.com/stomp-specification-1.2.html
44
+ #
45
+ # You are urged to become familiar with the specs. They are short documents.
46
+ #
47
+ # This includes:
48
+ #
49
+ # * The Stomp version(s) you wish the broker to consider
50
+ # * The broker vhost to connect to
51
+ #
52
+ # You may optionally specify other 1.1+ data:
53
+ #
54
+ # * heartbeat request
55
+ #
56
+ # Using the stomp gem, you should specify this data in the "connect_headers" Hash
57
+ # parameter. This example uses the common get_connection() method to
58
+ # get a connection.
59
+ #
60
+ class ConnectionPutExample
61
+ # Initialize
62
+ def initialize
63
+ end
64
+ # Run example
65
+ def run
66
+ #
67
+ # Get a connection
68
+ # ================
69
+ #
70
+ conn = get_connection()
71
+ #
72
+ # Let's just do some sanity checks, and look around.
73
+ #
74
+ raise "Connection failed!!" unless conn.open?()
75
+ #
76
+ # The broker _could_ have returned an ERROR frame (unlikely).
77
+ #
78
+ raise "Connect error: #{conn.connection_frame.body}" if conn.connection_frame.command == Stomp::CMD_ERROR
79
+ #
80
+ puts "Connection complete."
81
+ #
82
+ # Get Destination
83
+ #
84
+ qname = dest()
85
+ puts "Destination: #{qname}"
86
+ #
87
+ # Set Pace Time
88
+ #
89
+ pt = ENV['STOMP_PACETIME'] ? ENV['STOMP_PACETIME'].to_f : 15.0
90
+ puts "Pace Time: #{pt} seconds"
91
+ #
92
+ nm = nmsgs()
93
+ puts "Number of messages: #{nm}"
94
+ #
95
+ ph = {:persistent => true}
96
+ puts "Put Headers: #{ph}"
97
+ #
98
+ # Publish/put messages
99
+ #
100
+ puts "\nConnection start puts"
101
+ 1.upto(nm) do |n|
102
+ data = "message payload: #{n} #{Time.now.to_f}"
103
+ conn.publish(qname, data, ph)
104
+ puts "Sent: #{data}"
105
+ sleep pt
106
+ end
107
+ #
108
+ # Finally disconnect
109
+ # ==================
110
+ #
111
+ conn.disconnect() # Business as usual
112
+ puts "\nConnection disconnect complete"
113
+ end
114
+ end
115
+ #
116
+ e = ConnectionPutExample.new()
117
+ e.run
@@ -87,11 +87,18 @@ class ConnectionPutGetExample
87
87
  #
88
88
  puts "\nConnection start puts"
89
89
  nm = nmsgs()
90
+ ph = {:persistent => true}
91
+ ph['suppress_content_length'] = 'yes' if suppresscl()
92
+ puts "Put Headers: #{ph}"
90
93
  1.upto(nm) do |n|
91
94
  data = "message payload: #{n} #{Time.now.to_f}"
92
- conn.publish(qname, data)
95
+ conn.publish(qname, data, ph)
93
96
  puts "Sent: #{data}"
94
97
  end
98
+
99
+ #conn.disconnect()
100
+ #conn = get_connection()
101
+
95
102
  puts
96
103
  puts "Connection start receives"
97
104
  # Receives
@@ -14,6 +14,18 @@ class UserData
14
14
  "UserData: AuthorDate=>#{@ad}, AuthorDate=>#{@ad}, CommitCount =>#{@count}"
15
15
  end
16
16
  end
17
+ #
18
+ def partOne()
19
+ puts "# Contributors"
20
+ puts
21
+ puts "## Contributors (by first author date)"
22
+ puts
23
+ puts
24
+ puts "Contribution Information:"
25
+ puts
26
+ puts
27
+ end
28
+ #
17
29
  # tABLE Data
18
30
  ttab_s = "<table border=\"1\" style=\"width:100%;border: 1px solid black;\">\n"
19
31
  ttab_e = "</table>\n"
@@ -32,11 +44,12 @@ td_s = "<td style=\"border: 1px solid black;padding-left: 10px;\" >\n"
32
44
  td_e = "</td>\n"
33
45
  #
34
46
  #
47
+ partOne()
35
48
  userList = {}
36
49
  while s = gets do
37
50
  s.chomp!
38
51
  ##puts
39
- ##puts s
52
+ ##puts
40
53
  sa = s.split(" ")
41
54
  ## puts sa
42
55
  ad = sa[-1]
@@ -66,14 +66,7 @@ class Slogger
66
66
  def _init
67
67
  @log = Logger::new(STDOUT) # User preference
68
68
  @log.level = Logger::DEBUG # User preference
69
- end
70
-
71
- def marshal_dump
72
- []
73
- end
74
-
75
- def marshal_load(array)
76
- _init
69
+ @maxml = 100
77
70
  end
78
71
 
79
72
  # Log connecting events
@@ -98,6 +91,13 @@ class Slogger
98
91
  def on_connectfail(parms)
99
92
  begin
100
93
  @log.debug "Connect Fail #{info(parms)}"
94
+ @log.debug parms
95
+ @log.debug "Connect Fail Socket status: #{parms[:openstat]}"
96
+ if parms[:cur_failure]
97
+ @log.debug "Connect Fail Error Message: #{parms[:cur_failure].message}"
98
+ btr = parms[:cur_failure].backtrace.join("\n")
99
+ @log.debug "Backtrace CF: #{btr}"
100
+ end
101
101
  rescue
102
102
  @log.debug "Connect Fail oops"
103
103
  end
@@ -124,6 +124,19 @@ class Slogger
124
124
  begin
125
125
  @log.debug "Miscellaneous Error #{info(parms)}"
126
126
  @log.debug "Miscellaneous Error String #{errstr}"
127
+ @log.debug "Miscellaneous Error All Parms #{parms.inspect}"
128
+ if parms[:ssl_exception]
129
+ @log.debug "SSL Miscellaneous Error Parms: #{parms[:ssl_exception]}"
130
+ @log.debug "SSL Miscellaneous Error Message: #{parms[:ssl_exception].message}"
131
+ btr = parms[:ssl_execption].backtrace.join("\n")
132
+ @log.debug "Backtrace SME: #{btr}"
133
+ end
134
+ if parms[:cur_failure]
135
+ @log.debug "SSL Miscellaneous Error Parms2: #{parms[:cur_failure]}"
136
+ @log.debug "SSL Miscellaneous Error Message2: #{parms[:cur_failure].message}"
137
+ btr = parms[:cur_failure].backtrace.join("\n")
138
+ @log.debug "Backtrace SME2: #{btr}"
139
+ end
127
140
  rescue
128
141
  @log.debug "Miscellaneous Error oops"
129
142
  end
@@ -163,8 +176,10 @@ class Slogger
163
176
  # Log Receive
164
177
  def on_receive(parms, result)
165
178
  begin
166
- @log.debug "Receive Parms #{info(parms)}"
167
- @log.debug "Receive Result #{result}"
179
+ @log.debug "Receive Message, Command: #{result.command}"
180
+ pl = result.body.length < @maxml ? result.body.length : @maxml
181
+ @log.debug "Receive Message, Body: #{result.body[0..pl]}"
182
+ @log.debug "Receive Message, Headers: #{result.headers}"
168
183
  rescue
169
184
  @log.debug "Receive oops"
170
185
  end
@@ -262,7 +277,13 @@ class Slogger
262
277
  def on_ssl_connectfail(parms)
263
278
  begin
264
279
  @log.debug "SSL Connect Fail Parms #{info(parms)}"
265
- @log.debug "SSL Connect Fail Exception #{parms[:ssl_exception]}, #{parms[:ssl_exception].message}"
280
+ if parms[:ssl_exception]
281
+ @log.debug "SSL Connect Fail Exception Parms: #{parms[:ssl_exception]}"
282
+ @log.debug "SSL Connect Fail Message: #{parms[:ssl_exception].message}"
283
+ btr = parms[:ssl_exception].backtrace.join("\n")
284
+ @log.debug "Backtrace SCF: #{btr}"
285
+ end
286
+
266
287
  rescue
267
288
  @log.debug "SSL Connect Fail oops"
268
289
  end
@@ -278,6 +299,7 @@ class Slogger
278
299
  begin
279
300
  @log.debug "HeartBeat Fire Parms #{info(parms)}"
280
301
  @log.debug "HeartBeat Fire Send/Receive #{srind}"
302
+ @log.debug "HeartBeat Fire Firedata #{firedata.inspect}"
281
303
  rescue
282
304
  @log.debug "HeartBeat Fire oops"
283
305
  end