stomp 1.4.8 → 1.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c59a4e733516943028a09517af79ef6f83b364b25e6829235a867512580d8983
4
- data.tar.gz: 2822a29ebea5e99588b98a20689f0ae784e2e52cf43548fc88d5e7c6a35c1256
3
+ metadata.gz: af4124fc6712cdcd80e4f8c750e2be5cc4cd3f2dbb99c3d7b557bc14148a9a13
4
+ data.tar.gz: 18afb85efecbf3126909b419365d3f5c45360e8a5a9ddaaac4f43d69bef40aaf
5
5
  SHA512:
6
- metadata.gz: 72e141edc786894c8992f103a4fadfe00f34a45430960cb526a4c1867f12a0a25923579cd247cadf4e8b74c432cdc92f718d38a09cb5f0a1a11324324ead3587
7
- data.tar.gz: cedb2740f8b266c0893ad42b85e5799f5770269ff0a9eb7a5950f1950dd69fe7e2f0e8352a032e4adaf5ec30ae395f3093587ef51c9c5ca2f374239831899067
6
+ metadata.gz: 9fe7ee0a04e5fd4de9a2d4cde550d9cb2def32dc01d559a6daf2b4cb65d4135ae8089c905e9cfeee73d4e807da4cf860eb0401399b4348b507dce0b76523cfb0
7
+ data.tar.gz: 0c252981d37ab724868eb032b68f8892f149dd669f38460a5f256ec7cf4b1bbf6e9c67090c0840611cdc22daaceaf97cd021189bef45a3da057c6febd44cfb35
@@ -1,5 +1,16 @@
1
1
  # Stomp Gem Change Log
2
2
 
3
+ ## 1.4.9 20191116
4
+
5
+ * More debugging messages in netio.rb.
6
+ * Test workaround for Artemis-2289.
7
+ * New put and get examples.
8
+ * Fix issue #160.
9
+ * Address issue #155.
10
+ * Suppress SSL stacktrace to stdout.
11
+ * Example logger enhancements.
12
+ * Optional STOMP frame in examples.
13
+
3
14
  ## 1.4.8 20181219
4
15
 
5
16
  * Fix missed merge from 1.4.7 release.
data/README.md CHANGED
@@ -6,94 +6,97 @@
6
6
 
7
7
  An implementation of the Stomp protocol for Ruby. See:
8
8
 
9
- * [STOMP 1.0, 1.1, and 1.2] (http://stomp.github.com/index.html)
9
+ * [STOMP 1.0](http://stomp.github.io/stomp-specification-1.0.html)
10
+ * [STOMP 1.1](http://stomp.github.io/stomp-specification-1.1.html)
11
+ * [STOMP 1.2](http://stomp.github.io/stomp-specification-1.2.html)
10
12
 
11
13
  ## Hash Login Example Usage (**this is the recommended login technique**):
12
14
 
13
- ```
14
- hash = {
15
- :hosts => [
16
- # First connect is to remotehost1
17
- {:login => "login1", :passcode => "passcode1", :host => "remotehost1", :port => 61612, :ssl => true},
18
- # First failover connect is to remotehost2
19
- {:login => "login2", :passcode => "passcode2", :host => "remotehost2", :port => 61613, :ssl => false},
20
- ],
21
- # These are the default parameters and do not need to be set
22
- :reliable => true, # reliable (use failover)
23
- :initial_reconnect_delay => 0.01, # initial delay before reconnect (secs)
24
- :max_reconnect_delay => 30.0, # max delay before reconnect
25
- :use_exponential_back_off => true, # increase delay between reconnect attpempts
26
- :back_off_multiplier => 2, # next delay multiplier
27
- :max_reconnect_attempts => 0, # retry forever, use # for maximum attempts
28
- :randomize => false, # do not radomize hosts hash before reconnect
29
- :connect_timeout => 0, # Timeout for TCP/TLS connects, use # for max seconds
30
- :connect_headers => {}, # user supplied CONNECT headers (req'd for Stomp 1.1+)
31
- :parse_timeout => 5, # IO::select wait time on socket reads
32
- :logger => nil, # user suplied callback logger instance
33
- :dmh => false, # do not support multihomed IPV4 / IPV6 hosts during failover
34
- :closed_check => true, # check first if closed in each protocol method
35
- :hbser => false, # raise on heartbeat send exception
36
- :stompconn => false, # Use STOMP instead of CONNECT
37
- :usecrlf => false, # Use CRLF command and header line ends (1.2+)
38
- :max_hbread_fails => 0, # Max HB read fails before retry. 0 => never retry
39
- :max_hbrlck_fails => 0, # Max HB read lock obtain fails before retry. 0 => never retry
40
- :fast_hbs_adjust => 0.0, # Fast heartbeat senders sleep adjustment, seconds, needed ...
41
- # For fast heartbeat senders. 'fast' == YMMV. If not
42
- # correct for your environment, expect unnecessary fail overs
43
- :connread_timeout => 0, # Timeout during CONNECT for read of CONNECTED/ERROR, secs
44
- :tcp_nodelay => true, # Turns on the TCP_NODELAY socket option; disables Nagle's algorithm
45
- :start_timeout => 0, # Timeout around Stomp::Client initialization
46
- :sslctx_newparm => nil, # Param for SSLContext.new
47
- :ssl_post_conn_check => true, # Further verify broker identity
48
- :nto_cmd_read => true, # No timeout on COMMAND read
49
- }
15
+ ```ruby
16
+ hash = {
17
+ hosts: [
18
+ # First connect is to remotehost1
19
+ { login: 'login1', passcode: 'passcode1', host: 'remotehost1', port: 61_612, ssl: true },
20
+ # First failover connect is to remotehost2
21
+ { login: 'login2', passcode: 'passcode2', host: 'remotehost2', port: 61_613, ssl: false }
22
+ ],
23
+ # These are the default parameters and do not need to be set
24
+ reliable: true, # reliable (use failover)
25
+ initial_reconnect_delay: 0.01, # initial delay before reconnect (secs)
26
+ max_reconnect_delay: 30.0, # max delay before reconnect
27
+ use_exponential_back_off: true, # increase delay between reconnect attpempts
28
+ back_off_multiplier: 2, # next delay multiplier
29
+ max_reconnect_attempts: 0, # retry forever, use # for maximum attempts
30
+ randomize: false, # do not radomize hosts hash before reconnect
31
+ connect_timeout: 0, # Timeout for TCP/TLS connects, use # for max seconds
32
+ connect_headers: {}, # user supplied CONNECT headers (req'd for Stomp 1.1+)
33
+ parse_timeout: 5, # IO::select wait time on socket reads
34
+ logger: nil, # user suplied callback logger instance
35
+ dmh: false, # do not support multihomed IPV4 / IPV6 hosts during failover
36
+ closed_check: true, # check first if closed in each protocol method
37
+ hbser: false, # raise on heartbeat send exception
38
+ stompconn: false, # Use STOMP instead of CONNECT
39
+ usecrlf: false, # Use CRLF command and header line ends (1.2+)
40
+ max_hbread_fails: 0, # Max HB read fails before retry. 0 => never retry
41
+ max_hbrlck_fails: 0, # Max HB read lock obtain fails before retry. 0 => never retry
42
+ fast_hbs_adjust: 0.0, # Fast heartbeat senders sleep adjustment, seconds, needed ...
43
+ # For fast heartbeat senders. 'fast' == YMMV. If not
44
+ # correct for your environment, expect unnecessary fail overs
45
+ connread_timeout: 0, # Timeout during CONNECT for read of CONNECTED/ERROR, secs
46
+ tcp_nodelay: true, # Turns on the TCP_NODELAY socket option; disables Nagle's algorithm
47
+ start_timeout: 0, # Timeout around Stomp::Client initialization
48
+ sslctx_newparm: nil, # Param for SSLContext.new
49
+ ssl_post_conn_check: true, # Further verify broker identity
50
+ nto_cmd_read: true, # No timeout on COMMAND read
51
+ }
50
52
 
51
- # for a client
52
- client = Stomp::Client.new(hash)
53
+ # for a client
54
+ client = Stomp::Client.new(hash)
53
55
 
54
- # for a connection
55
- connection = Stomp::Connection.new(hash)
56
+ # for a connection
57
+ connection = Stomp::Connection.new(hash)
56
58
  ```
57
59
 
58
60
  ### Positional Parameter Usage:
59
61
 
60
- ```
61
- client = Stomp::Client.new("user", "pass", "localhost", 61613)
62
- client.publish("/queue/mine", "hello world!")
63
- client.subscribe("/queue/mine") do |msg|
64
- p msg
65
- end
62
+ ```ruby
63
+ client = Stomp::Client.new("user", "pass", "localhost", 61613)
64
+ client.publish("/queue/mine", "hello world!")
65
+ client.subscribe("/queue/mine") do |msg|
66
+ p msg
67
+ end
66
68
  ```
67
69
 
68
70
  ### Stomp URL Usage:
69
71
 
70
- A Stomp URL must begin with 'stomp://' and can be in one of the following forms:
72
+ A Stomp URL must begin with `stomp://` and can be in one of the following forms:
71
73
 
72
74
  ```
73
- stomp://host:port
74
- stomp://host.domain.tld:port
75
- stomp://login:passcode@host:port
76
- stomp://login:passcode@host.domain.tld:port
77
-
78
- # e.g. c = Stomp::Client.new(urlstring)
75
+ stomp://host:port
76
+ stomp://host.domain.tld:port
77
+ stomp://login:passcode@host:port
78
+ stomp://login:passcode@host.domain.tld:port
79
+
80
+ # e.g. c = Stomp::Client.new(urlstring)
79
81
  ```
80
82
 
81
83
  ### Failover + SSL Example URL Usage:
82
84
 
83
- ```
84
- options = "initialReconnectDelay=5000&randomize=false&useExponentialBackOff=false"
85
- # remotehost1 uses SSL, remotehost2 doesn't
86
- client = Stomp::Client.new("failover:(stomp+ssl://login1:passcode1@remotehost1:61612,stomp://login2:passcode2@remotehost2:61613)?#{options}")
87
- client.publish("/queue/mine", "hello world!")
88
- client.subscribe("/queue/mine") do |msg|
89
- p msg
90
- end
85
+ ```ruby
86
+ options = 'initialReconnectDelay=5000&randomize=false&useExponentialBackOff=false'
87
+ # remotehost1 uses SSL, remotehost2 doesn't
88
+ client = Stomp::Client.new("failover:(stomp+ssl://login1:passcode1@remotehost1:61612,stomp://login2:passcode2@remotehost2:61613)?#{options}")
89
+ client.publish('/queue/mine', 'hello world!')
90
+ client.subscribe('/queue/mine') do |msg|
91
+ p msg
92
+ end
91
93
  ```
92
94
 
93
95
  ### New:
94
96
 
95
97
  See _CHANGELOG.rdoc_ for details.
96
98
 
99
+ * Gem version 1.4.9. Fix two issues, enhance debugging and examples.
97
100
  * Gem version 1.4.8. Fix missed merge in 1.4.7 release.
98
101
  * Gem version 1.4.7. Add support for text SSL certs. Do not use, use 1.4.8 instead.
99
102
  * Gem version 1.4.6. Fix version 1.4.5 which breaks JRuby support.
@@ -322,7 +325,7 @@ Rafael Rosa
322
325
  2010-03-23
323
326
  </td>
324
327
  <td style="border: 1px solid black;padding-left: 10px;" >
325
- (0092)
328
+ (0106)
326
329
  </td>
327
330
  <td style="border: 1px solid black;padding-left: 10px;" >
328
331
  <span style="font-weight: bold;" >
@@ -821,4 +824,32 @@ Katharine
821
824
  / &lt;krsibbald@gmail.com&gt;
822
825
  </td>
823
826
  </tr>
827
+ <tr>
828
+ <td style="border: 1px solid black;padding-left: 10px;" >
829
+ 2019-06-05
830
+ </td>
831
+ <td style="border: 1px solid black;padding-left: 10px;" >
832
+ (0001)
833
+ </td>
834
+ <td style="border: 1px solid black;padding-left: 10px;" >
835
+ <span style="font-weight: bold;" >
836
+ Smit Patel
837
+ </span>
838
+ / &lt;smitpatel24@gmail.com&gt;
839
+ </td>
840
+ </tr>
841
+ <tr>
842
+ <td style="border: 1px solid black;padding-left: 10px;" >
843
+ 2019-09-16
844
+ </td>
845
+ <td style="border: 1px solid black;padding-left: 10px;" >
846
+ (0001)
847
+ </td>
848
+ <td style="border: 1px solid black;padding-left: 10px;" >
849
+ <span style="font-weight: bold;" >
850
+ Thiago Xavier
851
+ </span>
852
+ / &lt;thiagoxvo@gmail.com&gt;
853
+ </td>
854
+ </tr>
824
855
  </table>
@@ -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
@@ -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
@@ -40,6 +40,9 @@ class LoggerExample
40
40
  # //////////////////////////////////////////////////////////////////////////////
41
41
  # A hash type connect *MUST* be used to enable callback logging.
42
42
  # //////////////////////////////////////////////////////////////////////////////
43
+ # Note: running this example will generate a number of connect failures,
44
+ # because of the fake host in this connect hash.
45
+ # //////////////////////////////////////////////////////////////////////////////
43
46
  hash = { :hosts => [
44
47
  {:login => user, :passcode => password, :host => 'noonehome', :port => 2525,
45
48
  :ssl => so},
@@ -38,7 +38,7 @@ class FilePutGet
38
38
  conn = get_connection()
39
39
  puts "pgf005: Qname is: #{@qname}"
40
40
  # Try to gracefully handle files that exceed broker size limits.
41
- ph = {:presistent => true}
41
+ ph = {:persistent => true}
42
42
  ph['suppress_content_length'] = 'yes' if suppresscl()
43
43
  puts "pgf006: Headers are: #{ph.inspect}"
44
44
  begin
@@ -76,4 +76,4 @@ end
76
76
  #
77
77
  e = FilePutGet.new()
78
78
  e.doput()
79
- e.doget()
79
+ # e.doget()
@@ -55,6 +55,7 @@ module Stomp1xCommon
55
55
  ],
56
56
  :connect_headers => conn_hdrs,
57
57
  }
58
+ conn_hash[:stompconn] = ENV["STOMP_USESTOMP"] ? true : false
58
59
  conn = Stomp::Connection.new(conn_hash)
59
60
  end
60
61
 
@@ -175,6 +175,7 @@ module Stomp
175
175
  @replay_messages_by_txn = {}
176
176
 
177
177
  @listener_map = Hash.new do |message|
178
+ @failure = nil
178
179
  unless @connection.slog(:on_miscerr, @connection.log_params, "Received unknown frame type: '#{message.command}'\n")
179
180
  warn "Received unknown frame type: '#{message.command}'\n"
180
181
  end
@@ -156,7 +156,8 @@ module Stomp
156
156
  raise sfex
157
157
  end
158
158
  #
159
- if @protocol >= Stomp::SPL_11 && msg.command != Stomp::CMD_CONNECTED
159
+ # Always decode headers, even for 1.0. Issue #160.
160
+ if msg.command != Stomp::CMD_CONNECTED
160
161
  msg.headers = _decodeHeaders(msg.headers)
161
162
  end
162
163
  p [ "_receive_ends", msg.command, msg.headers ] if drdbg
@@ -227,9 +228,10 @@ module Stomp
227
228
  dtrdbg = ENV['DTRDBG'] ? true : false
228
229
  # p [ "wirewrite" ]
229
230
  # _dump_callstack()
230
-
231
+ p [ "_transmit_headers_in1", headers ] if dtrdbg
231
232
  if @protocol >= Stomp::SPL_11 && command != Stomp::CMD_CONNECT
232
233
  headers = _encodeHeaders(headers)
234
+ p [ "_transmit_headers_in2", headers ] if dtrdbg
233
235
  end
234
236
  @transmit_semaphore.synchronize do
235
237
  p [ "_transmit_lock", Thread::current() ] if dtrdbg
@@ -248,7 +250,9 @@ module Stomp
248
250
  # Lets send this header in the message, so it can maintain state when using unreceive
249
251
  headers[:'content-length'] = "#{body_length_bytes}" unless headers[:suppress_content_length]
250
252
  headers[:'content-type'] = "text/plain; charset=UTF-8" unless headers[:'content-type'] || headers[:suppress_content_type]
253
+ p [ "_transmit_command", command ] if dtrdbg
251
254
  _wire_write(used_socket,command)
255
+ p [ "_transmit_headers", headers ] if dtrdbg
252
256
  headers.each do |k,v|
253
257
  if v.is_a?(Array)
254
258
  v.each do |e|
@@ -258,8 +262,10 @@ module Stomp
258
262
  _wire_write(used_socket,"#{k}:#{v}")
259
263
  end
260
264
  end
265
+ p [ "_transmit_headers done" ] if dtrdbg
261
266
  _wire_write(used_socket,"")
262
267
  if body != ''
268
+ p [ "_transmit_body", body ] if dtrdbg
263
269
  if headers[:suppress_content_length]
264
270
  if tz = body.index("\00")
265
271
  used_socket.write body[0..tz-1]
@@ -271,7 +277,8 @@ module Stomp
271
277
  end
272
278
  end
273
279
  used_socket.write "\0"
274
- used_socket.flush if autoflush
280
+ # used_socket.flush if autoflush
281
+ used_socket.flush
275
282
 
276
283
  if @protocol >= Stomp::SPL_11
277
284
  @ls = Time.now.to_f if @hbs
@@ -321,6 +328,7 @@ module Stomp
321
328
  # open_ssl_socket opens an SSL socket.
322
329
  def open_ssl_socket()
323
330
  require 'openssl' unless defined?(OpenSSL)
331
+ ossdbg = ENV['OSSDBG'] ? true : false
324
332
  begin # Any raised SSL exceptions
325
333
  ctx = @sslctx_newparm ? OpenSSL::SSL::SSLContext.new(@sslctx_newparm) : OpenSSL::SSL::SSLContext.new
326
334
  ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # Assume for now
@@ -366,37 +374,66 @@ module Stomp
366
374
  end
367
375
  ctx.cert_store = truststores
368
376
  end
369
-
377
+ #
378
+ p [ "OSSL50", "old code starts" ] if ossdbg
379
+ usecert = nil
380
+ usekey = nil
370
381
  # Client authentication
371
382
  # If cert exists as a file, then it should not be input as text
372
- raise Stomp::Error::SSLClientParamsError if !@ssl.cert_file.nil? && !@ssl.cert_text.nil?
383
+ raise Stomp::Error::SSLClientParamsError if !@ssl.cert_file.nil? &&
384
+ !@ssl.cert_text.nil?
373
385
  # If cert exists as file, then key must exist, either as text or file
374
- raise Stomp::Error::SSLClientParamsError if !@ssl.cert_file.nil? && @ssl.key_file.nil? && @ssl.key_text.nil?
386
+ raise Stomp::Error::SSLClientParamsError if !@ssl.cert_file.nil? &&
387
+ @ssl.key_file.nil? && @ssl.key_text.nil?
375
388
  if @ssl.cert_file
376
389
  raise Stomp::Error::SSLNoCertFileError if !File::exists?(@ssl.cert_file)
377
390
  raise Stomp::Error::SSLUnreadableCertFileError if !File::readable?(@ssl.cert_file)
378
- ctx.cert = OpenSSL::X509::Certificate.new(File.read(@ssl.cert_file))
391
+ p [ "OSSL51", "old code cert file read" ] if ossdbg
392
+ usecert = OpenSSL::X509::Certificate.new(File.read(@ssl.cert_file))
379
393
  end
380
-
381
394
  # If cert exists as file, then key must exist, either as text or file
382
- raise Stomp::Error::SSLClientParamsError if !@ssl.cert_text.nil? && @ssl.key_file.nil? && @ssl.key_text.nil?
395
+ raise Stomp::Error::SSLClientParamsError if !@ssl.cert_text.nil? &&
396
+ @ssl.key_file.nil? && @ssl.key_text.nil?
383
397
  if @ssl.cert_text
384
- ctx.cert = OpenSSL::X509::Certificate.new(@ssl.cert_text)
398
+ p [ "OSSL52", "old code cert text get" ] if ossdbg
399
+ usecert = OpenSSL::X509::Certificate.new(@ssl.cert_text)
385
400
  end
386
401
 
387
402
  # If key exists as a text, then it should not be input as file
388
- raise Stomp::Error::SSLClientParamsError if !@ssl.key_text.nil? && !@ssl.key_file.nil?
403
+ raise Stomp::Error::SSLClientParamsError if !@ssl.key_text.nil? &&
404
+ !@ssl.key_file.nil?
389
405
  if @ssl.key_file
390
406
  raise Stomp::Error::SSLNoKeyFileError if !File::exists?(@ssl.key_file)
391
407
  raise Stomp::Error::SSLUnreadableKeyFileError if !File::readable?(@ssl.key_file)
392
- ctx.key = OpenSSL::PKey::RSA.new(File.read(@ssl.key_file), @ssl.key_password)
408
+ p [ "OSSL53", "old code key file read" ] if ossdbg
409
+ usekey = OpenSSL::PKey::RSA.new(File.read(@ssl.key_file), @ssl.key_password)
393
410
  end
394
411
 
395
412
  if @ssl.key_text
396
413
  nt = @ssl.key_text.gsub(/\t/, "")
397
- ctx.key = OpenSSL::PKey::RSA.new(nt, @ssl.key_password)
414
+ p [ "OSSL54", "old code key text get" ] if ossdbg
415
+ usekey = OpenSSL::PKey::RSA.new(nt, @ssl.key_password)
398
416
  end
399
-
417
+ #
418
+ # This style of code because: in newer Ruby versions the 'cert'
419
+ # and 'key' attributes are deprecated. It is suggested that the
420
+ # 'add_certificate' method be used instead.
421
+ #
422
+ if ctx.respond_to?(:add_certificate) # Newer Ruby version ??
423
+ p [ "OSSL55", "new code option", usecert, usekey ] if ossdbg
424
+ if !usecert.nil? && !usekey.nil?
425
+ p [ "OSSL55", "new code add_certificate" ] if ossdbg
426
+ ctx.add_certificate(usecert, usekey)
427
+ else
428
+ p [ "OSSL56", "new code SKIP add_certificate" ] if ossdbg
429
+ end
430
+ else
431
+ # Older Ruby versions
432
+ p [ "OSSL56", "old code option", usecert, usekey ] if ossdbg
433
+ ctx.cert = usecert
434
+ ctx.key = usekey
435
+ end
436
+ p [ "OSSL99", "old code ends" ] if ossdbg
400
437
  # Cipher list
401
438
  # As of this writing, there are numerous problems with supplying
402
439
  # cipher lists to jruby. So we do not attempt to do that here.
@@ -457,8 +494,8 @@ module Stomp
457
494
  ssl.close
458
495
  end
459
496
  #
460
- puts ex.backtrace
461
- $stdout.flush
497
+ puts ex.backtrace if ossdbg
498
+ $stdout.flush if ossdbg
462
499
  raise # Reraise
463
500
  end
464
501
  end
@@ -252,6 +252,7 @@ module Stomp
252
252
  noiosel = (@ssl || @jruby) ? true : false
253
253
  return _receive(used_socket, connread, noiosel)
254
254
  rescue Stomp::Error::MaxReconnectAttempts
255
+ @failure = $!
255
256
  unless slog(:on_miscerr, log_params, "Reached MaxReconnectAttempts")
256
257
  $stderr.print "Reached MaxReconnectAttempts\n"
257
258
  end
@@ -492,6 +492,7 @@ module Stomp
492
492
  super_result = __old_receive()
493
493
  if super_result.nil? && @reliable && !closed?
494
494
  errstr = "connection.receive returning EOF as nil - resetting connection.\n"
495
+ @failure = nil
495
496
  unless slog(:on_miscerr, log_params, "es_recv: " + errstr)
496
497
  $stderr.print errstr
497
498
  end
@@ -6,7 +6,7 @@ module Stomp
6
6
  module Version #:nodoc: all
7
7
  MAJOR = 1
8
8
  MINOR = 4
9
- PATCH = 8
9
+ PATCH = 9
10
10
  # PATCH = "8.plvl.001"
11
11
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
12
12
  end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: stomp 1.4.8 ruby lib
5
+ # stub: stomp 1.4.9 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "stomp".freeze
9
- s.version = "1.4.8"
9
+ s.version = "1.4.9"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Brian McCallister".freeze, "Marius Mathiesen".freeze, "Thiago Morello".freeze, "Guy M. Allard".freeze]
14
- s.date = "2018-12-19"
14
+ s.date = "2019-11-16"
15
15
  s.description = "Ruby client for the Stomp messaging protocol.".freeze
16
16
  s.email = ["brianm@apache.org".freeze, "marius@stones.com".freeze, "morellon@gmail.com".freeze, "allard.guy.m@gmail.com".freeze]
17
17
  s.executables = ["catstomp".freeze, "stompcat".freeze]
@@ -42,6 +42,9 @@ Gem::Specification.new do |s|
42
42
  "examples/client_conndisc.rb",
43
43
  "examples/client_putget.rb",
44
44
  "examples/conn_conndisc.rb",
45
+ "examples/conn_get.rb",
46
+ "examples/conn_put.rb",
47
+ "examples/conn_put_pace.rb",
45
48
  "examples/conn_putget.rb",
46
49
  "examples/contrib.sh",
47
50
  "examples/contributors.rb",
@@ -84,7 +84,9 @@ class TestAnonymous < Test::Unit::TestCase
84
84
  p [ "01", mn, "starts" ] if @tandbg
85
85
  conn_subscribe make_destination, :receipt => "abc"
86
86
  msg = @conn.receive
87
- assert_equal "abc", msg.headers['receipt-id']
87
+ tval = msg.headers['receipt-id']
88
+ tval = msg.headers['receipt-id'][0] if msg.headers['receipt-id'].is_a?(Array)
89
+ assert_equal "abc", tval
88
90
  checkEmsg(@conn)
89
91
  p [ "99", mn, "ends" ] if @tandbg
90
92
  end
@@ -82,9 +82,14 @@ class TestConnection < Test::Unit::TestCase
82
82
  def test_receipt
83
83
  mn = "test_receipt" if @tcndbg
84
84
  p [ "01", mn, "starts" ] if @tcndbg
85
+ p [ "02", @conn.protocol ] if @tcndbg
85
86
  conn_subscribe make_destination, :receipt => "abc"
86
87
  msg = @conn.receive
87
- assert_equal "abc", msg.headers['receipt-id']
88
+ p [ "05", msg.headers['receipt-id'].class, msg.headers['receipt-id'].is_a?(Array) ] if @tcndbg
89
+ #
90
+ tval = msg.headers['receipt-id']
91
+ tval = msg.headers['receipt-id'][0] if msg.headers['receipt-id'].is_a?(Array)
92
+ assert_equal "abc", tval
88
93
  checkEmsg(@conn)
89
94
  p [ "99", mn, "ends" ] if @tcndbg
90
95
  end
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.8
4
+ version: 1.4.9
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: 2018-12-19 00:00:00.000000000 Z
14
+ date: 2019-11-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
@@ -69,6 +69,9 @@ files:
69
69
  - examples/client_conndisc.rb
70
70
  - examples/client_putget.rb
71
71
  - examples/conn_conndisc.rb
72
+ - examples/conn_get.rb
73
+ - examples/conn_put.rb
74
+ - examples/conn_put_pace.rb
72
75
  - examples/conn_putget.rb
73
76
  - examples/contrib.sh
74
77
  - examples/contributors.rb