stomp 1.1.10 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,20 @@
1
+ == 1.2.0 2011-14-12
2
+
3
+ * Stomp 1.1 protocol support. A significant change. Please test existing 1.0 code well. See the examples directory for 1.1 examples.
4
+ * Accept :reliable in a Stomp::Client connection hash
5
+ * Add connect timeout with hashed parameters
6
+ * Do not allow calls after close/disconnect
7
+ * Enhance supported logger callbacks
8
+ * Fix subscription id in find_listener
9
+ * Start to bootstrap STOMP 1.1 support
10
+
11
+ == 1.1.10 2011-07-11
12
+
13
+ * Fixes for JRuby support
14
+ * Fix EOF error on disconnect
15
+ * Refactoring and additional test
16
+ * Set up tests for use of RabbitMQ
17
+
1
18
  == 1.1.9 2011-15-06
2
19
 
3
20
  * Support wildcard destinations
data/README.rdoc CHANGED
@@ -8,9 +8,11 @@
8
8
 
9
9
  An implementation of the Stomp protocol for Ruby. See:
10
10
 
11
- * [STOMP 1.0] (http://stomp.codehaus.org/Protocol)
12
- * [STOMP 1.0 and 1.1 Draft] (http://stomp.github.com/index.html)
11
+ * [STOMP 1.0 and 1.1] (http://stomp.github.com/index.html)
13
12
 
13
+ ===New
14
+
15
+ Support of Stomp protocol level 1.1 is announced as of gem version 1.2.0.
14
16
 
15
17
  ===Example Usage
16
18
 
@@ -83,7 +85,6 @@ Project Home :
83
85
  Stomp Protocol Info :
84
86
 
85
87
  http://stomp.github.com/index.html
86
- http://stomp.codehaus.org/Protocol
87
88
 
88
89
  = Contributors
89
90
 
@@ -104,4 +105,11 @@ The following people have contributed to Stomp:
104
105
  * Dinesh Majrekar
105
106
  * Kiall Mac Innes
106
107
  * Rob Skaggs
108
+ * Tom May
109
+ * Lucas Hills
110
+ * Chris Needham
111
+ * R.I. Pienaar
112
+ * tworker
113
+
114
+
107
115
 
data/Rakefile CHANGED
@@ -30,10 +30,10 @@ begin
30
30
  gem.name = "stomp"
31
31
  gem.version = Stomp::Version::STRING
32
32
  gem.summary = %Q{Ruby client for the Stomp messaging protocol}
33
- gem.description = %Q{Ruby client for the Stomp messaging protocol}
33
+ gem.description = %Q{Ruby client for the Stomp messaging protocol. Note that this gem is no longer supported on rubyforge.}
34
34
  gem.email = ["brianm@apache.org", 'marius@stones.com', 'morellon@gmail.com',
35
35
  'allard.guy.m@gmail.com' ]
36
- gem.homepage = "https://rubygems.org/gems/stomp"
36
+ gem.homepage = "https://github.com/morellon/stomp"
37
37
  gem.authors = ["Brian McCallister", 'Marius Mathiesen', 'Thiago Morello',
38
38
  'Guy M. Allard']
39
39
  gem.add_development_dependency "rspec", '>= 2.3'
data/bin/catstomp CHANGED
@@ -18,13 +18,13 @@ begin; require 'rubygems'; rescue; end
18
18
  require 'stomp'
19
19
 
20
20
  #
21
- # This simple script is inspired by the netcat utility. It allows you to send
21
+ # This simple script is inspired by the netcat utility. It allows you to publish
22
22
  # input into this process to stomp destination.
23
23
  #
24
24
  # Usage: catstomp (destination-name)
25
25
  #
26
26
  # Example: ls | catstomp /topic/foo
27
- # Would send the output of the ls command to the stomp destination /topic/foo
27
+ # Would publish the output of the ls command to the stomp destination /topic/foo
28
28
  #
29
29
  begin
30
30
 
@@ -47,7 +47,7 @@ begin
47
47
  @headers['reply-to'] = $*[1] if $*[1] != nil
48
48
 
49
49
  STDIN.each_line { |line|
50
- @conn.send @destination, line, @headers
50
+ @conn.publish @destination, line, @headers
51
51
  }
52
52
 
53
53
  rescue
@@ -0,0 +1,78 @@
1
+ #
2
+ # The current require dance for different Ruby versions.
3
+ # Change this to suit your requirements.
4
+ #
5
+ if Kernel.respond_to?(:require_relative)
6
+ require_relative("./stomp11_common")
7
+ else
8
+ $LOAD_PATH << File.dirname(__FILE__)
9
+ require "stomp11_common"
10
+ end
11
+ include Stomp11Common
12
+ #
13
+ # Stomp 1.1 Client Example 1
14
+ # ==============================
15
+ #
16
+ # Purpose: to demonstrate a clientect and disclientect sequence using Stomp 1.1
17
+ # with the Stomp#client intreface.
18
+ #
19
+ # Note: Stomp#client does not provide a positional set of parameters that
20
+ # contain a 'clientect_headers' parameter. To use the Stomp#client interface
21
+ # you _must_ use a 'hashed' set of parameters.
22
+ #
23
+ # Create connection headers
24
+ # =========================
25
+ #
26
+ # The two headers used here are _required_ by the specification.
27
+ #
28
+ client_hdrs = {"accept-version" => "1.1", # Demand a 1.1 connection (use a CSV list if you will consider multiple versions)
29
+ "host" => virt_host, # The 1.1 vhost (could be different than connection host)
30
+ } # No heartbeats here: there will be none for this connection
31
+ #
32
+ # Create the connect hash.
33
+ # ========================
34
+ #
35
+ client_hash = { :hosts => [
36
+ {:login => login, :passcode => passcode, :host => host, :port => port},
37
+ ],
38
+ :connect_headers => client_hdrs,
39
+ }
40
+ #
41
+ # Get a connection
42
+ # ================
43
+ #
44
+ client = Stomp::Client.new(client_hash)
45
+ puts "Connection complete"
46
+ #
47
+ # Let's just do some sanity checks, and look around.
48
+ #
49
+ raise "Connection failed!!" unless client.open?
50
+ #
51
+ # Is this really a 1.1 conection? (For clients, 'protocol' is a public method.
52
+ # The value will be '1.0' for those types of connections.)
53
+ #
54
+ raise "Unexpected protocol level" if client.protocol() != Stomp::SPL_11
55
+ #
56
+ # The broker _could_ have returned an ERROR frame (unlikely).
57
+ # For clients, 'connection_frame' is a public method.
58
+ #
59
+ raise "Connect error: #{client.connection_frame().body}" if client.connection_frame().command == Stomp::CMD_ERROR
60
+ #
61
+ # Examine the CONNECT response (the connection_frame()).
62
+ #
63
+ puts "Connected Headers required to be present:"
64
+ puts "Connect version - \t#{client.connection_frame().headers['version']}"
65
+ puts
66
+ puts "Connected Headers that are optional:"
67
+ puts "Connect broker - \t\t#{client.connection_frame().headers['broker']}"
68
+ puts "Session ID - \t\t\t#{client.connection_frame().headers['session']}"
69
+ puts "Server requested heartbeats - \t#{client.connection_frame().headers['heart-beat']}"
70
+ #
71
+ # Finally close
72
+ # =============
73
+ #
74
+ client.close # Business as usual, just like 1.0
75
+ puts "Disclientect complete"
76
+
77
+
78
+
@@ -0,0 +1,57 @@
1
+ #
2
+ # The current require dance for different Ruby versions.
3
+ # Change this to suit your requirements.
4
+ #
5
+ if Kernel.respond_to?(:require_relative)
6
+ require_relative("./stomp11_common")
7
+ else
8
+ $LOAD_PATH << File.dirname(__FILE__)
9
+ require "stomp11_common"
10
+ end
11
+ include Stomp11Common
12
+ #
13
+ # Stomp 1.1 Client Putter/Getter Example 1
14
+ # ========================================
15
+ #
16
+ # This is much like sending and receiving with a Stomp::Connection.
17
+ #
18
+ client_hdrs = {"accept-version" => "1.1", # Demand a 1.1 connection (use a CSV list if you will consider multiple versions)
19
+ "host" => virt_host, # The 1.1 vhost (could be different than connection host)
20
+ } # No heartbeats here: there will be none for this connection
21
+ #
22
+ client_hash = { :hosts => [
23
+ {:login => login, :passcode => passcode, :host => host, :port => port},
24
+ ],
25
+ :connect_headers => client_hdrs,
26
+ }
27
+ #
28
+ client = Stomp::Client.new(client_hash)
29
+ puts "Connection complete"
30
+ #
31
+ raise "Unexpected protocol level" if client.protocol() != Stomp::SPL_11
32
+ #
33
+ qname = "/queue/client.nodea.nodeb.nodec"
34
+ data = "message payload: #{Time.now.to_f}"
35
+ headers = {}
36
+ # Send it
37
+ client.publish qname, data
38
+ # Receive
39
+ uuid = client.uuid() # uuid for Stomp::Client is a public method
40
+ message = nil
41
+ # Clients must pass a receive block. This is business as usual, required for 1.0.
42
+ # For 1.1, a unique subscription id is required.
43
+ client.subscribe(qname, {'id' => uuid}) {|m|
44
+ message = m
45
+ }
46
+ sleep 0.1 until message # Wait for completion
47
+ # Unsubscribe, with the unique id
48
+ client.unsubscribe qname, {'id' => uuid}
49
+ # Sanity checks for this example ....
50
+ raise "Unexpected data" if data != message.body
51
+ raise "Bad subscription header" if uuid != message.headers['subscription']
52
+ #
53
+ client.close # Business as usual, just like 1.0
54
+ puts "Disclientect complete"
55
+
56
+
57
+
@@ -0,0 +1,101 @@
1
+ #
2
+ # The current require dance for different Ruby versions.
3
+ # Change this to suit your requirements.
4
+ #
5
+ if Kernel.respond_to?(:require_relative)
6
+ require_relative("./stomp11_common")
7
+ else
8
+ $LOAD_PATH << File.dirname(__FILE__)
9
+ require "stomp11_common"
10
+ end
11
+ include Stomp11Common
12
+ #
13
+ # Stomp 1.1 Connection Example 1
14
+ # ==============================
15
+ #
16
+ # Purpose: to demonstrate a connect and disconnect sequence using Stomp 1.1.
17
+ #
18
+ # Note: this example assumes that you have at least the 1.1.11 gem release
19
+ # installed.
20
+ #
21
+ # When you:
22
+ #
23
+ # * Use a Stomp 1.1 compliant broker
24
+ # * Want a Stomp 1.1 level connection and functionality
25
+ #
26
+ # then your code *must* specifically request that environment.
27
+ #
28
+ # You need to supply all of the normal values expected of course:
29
+ #
30
+ # * login - the user name
31
+ # * passcode - the password
32
+ # * host - the host to connect to
33
+ # * port - the port to connect to
34
+ #
35
+ # Additionaly you are required to supply the 1.1 connection data as documented
36
+ # in the Stomp 1.1 specification: http://stomp.github.com/stomp-specification-1.1.html
37
+ # You are urged to become familiar with the spec. It is a short document.
38
+ #
39
+ # This includes:
40
+ #
41
+ # * The Stomp version(s) you wish the broker to consider
42
+ # * The broker vhost to connect to
43
+ #
44
+ # You may optionally specify other 1.1 data:
45
+ #
46
+ # * heartbeat request
47
+ #
48
+ # Using the stomp gem, you specify this data in the "connect_headers" Hash
49
+ # parameter.
50
+ #
51
+ # So .........
52
+ #
53
+ # Create connection headers
54
+ # =========================
55
+ #
56
+ # The two headers used here are _required_ by the specification.
57
+ #
58
+ conn_hdrs = {"accept-version" => "1.1", # Demand a 1.1 connection (use a CSV list if you will consider multiple versions)
59
+ "host" => virt_host, # The 1.1 vhost (could be different than connection host)
60
+ } # No heartbeats here: there will be none for this connection
61
+ #
62
+ # Get a connection
63
+ # ================
64
+ #
65
+ conn = Stomp::Connection.new(login, passcode, host, port, # Normal connect parms
66
+ false, # Not reliable, the default
67
+ 5, # Connect redelay, the default
68
+ conn_hdrs) # The 1.1 connection parameters
69
+ puts "Connection complete"
70
+ #
71
+ # Let's just do some sanity checks, and look around.
72
+ #
73
+ raise "Connection failed!!" unless conn.open?
74
+ #
75
+ # Is this really a 1.1 conection? ('protocol' is a read only connection
76
+ # instance variable. The value will be '1.0' for those types of connections.)
77
+ #
78
+ raise "Unexpected protocol level" if conn.protocol != Stomp::SPL_11
79
+ #
80
+ # The broker _could_ have returned an ERROR frame (unlikely).
81
+ #
82
+ raise "Connect error: #{conn.connection_frame.body}" if conn.connection_frame.command == Stomp::CMD_ERROR
83
+ #
84
+ # Examine the CONNECT response (the connection_frame).
85
+ #
86
+ puts "Connected Headers required to be present:"
87
+ puts "Connect version - \t#{conn.connection_frame.headers['version']}"
88
+ puts
89
+ puts "Connected Headers that are optional:"
90
+ puts "Connect broker - \t\t#{conn.connection_frame.headers['broker']}"
91
+ puts "Session ID - \t\t\t#{conn.connection_frame.headers['session']}"
92
+ puts "Server requested heartbeats - \t#{conn.connection_frame.headers['heart-beat']}"
93
+ #
94
+ # Finally disconnect
95
+ # ==================
96
+ #
97
+ conn.disconnect # Business as usual, just like 1.0
98
+ puts "Disconnect complete"
99
+
100
+
101
+
@@ -0,0 +1,75 @@
1
+ #
2
+ # The current require dance for different Ruby versions.
3
+ # Change this to suit your requirements.
4
+ #
5
+ if Kernel.respond_to?(:require_relative)
6
+ require_relative("./stomp11_common")
7
+ else
8
+ $LOAD_PATH << File.dirname(__FILE__)
9
+ require "stomp11_common"
10
+ end
11
+ include Stomp11Common
12
+ #
13
+ # Stomp 1.1 Connection Example 1
14
+ # ==============================
15
+ #
16
+ # Purpose: to demonstrate a connect and disconnect sequence using Stomp 1.1.
17
+ #
18
+ # This example is like the 'conn11_ex1.rb' example except that a 'hashed'
19
+ # connect request is made.
20
+ #
21
+ # Create connection headers
22
+ # =========================
23
+ #
24
+ # The two headers used here are _required_ by the specification.
25
+ #
26
+ conn_hdrs = {"accept-version" => "1.1", # Demand a 1.1 connection (use a CSV list if you will consider multiple versions)
27
+ "host" => virt_host, # The 1.1 vhost (could be different than connection host)
28
+ } # No heartbeats here: there will be none for this connection
29
+ #
30
+ # Create the connect hash.
31
+ # ========================
32
+ #
33
+ conn_hash = { :hosts => [
34
+ {:login => login, :passcode => passcode, :host => host, :port => port},
35
+ ],
36
+ :connect_headers => conn_hdrs,
37
+ }
38
+ #
39
+ # Get a connection
40
+ # ================
41
+ #
42
+ conn = Stomp::Connection.new(conn_hash)
43
+ puts "Connection complete"
44
+ #
45
+ # Let's just do some sanity checks, and look around.
46
+ #
47
+ raise "Connection failed!!" unless conn.open?
48
+ #
49
+ # Is this really a 1.1 conection? ('protocol' is a read only connection
50
+ # instance variable. The value will be '1.0' for those types of connections.)
51
+ #
52
+ raise "Unexpected protocol level" if conn.protocol != Stomp::SPL_11
53
+ #
54
+ # The broker _could_ have returned an ERROR frame (unlikely).
55
+ #
56
+ raise "Connect error: #{conn.connection_frame.body}" if conn.connection_frame.command == Stomp::CMD_ERROR
57
+ #
58
+ # Examine the CONNECT response (the connection_frame).
59
+ #
60
+ puts "Connected Headers required to be present:"
61
+ puts "Connect version - \t#{conn.connection_frame.headers['version']}"
62
+ puts
63
+ puts "Connected Headers that are optional:"
64
+ puts "Connect broker - \t\t#{conn.connection_frame.headers['broker']}"
65
+ puts "Session ID - \t\t\t#{conn.connection_frame.headers['session']}"
66
+ puts "Server requested heartbeats - \t#{conn.connection_frame.headers['heart-beat']}"
67
+ #
68
+ # Finally disconnect
69
+ # ==================
70
+ #
71
+ conn.disconnect # Business as usual, just like 1.0
72
+ puts "Disconnect complete"
73
+
74
+
75
+
@@ -0,0 +1,46 @@
1
+ #
2
+ # The current require dance for different Ruby versions.
3
+ # Change this to suit your requirements.
4
+ #
5
+ if Kernel.respond_to?(:require_relative)
6
+ require_relative("./stomp11_common")
7
+ require_relative("./slogger")
8
+ else
9
+ $LOAD_PATH << File.dirname(__FILE__)
10
+ require "stomp11_common"
11
+ require "slogger"
12
+ end
13
+ include Stomp11Common
14
+ #
15
+ # Stomp 1.1 Heartbeat Example 1
16
+ # =============================
17
+ #
18
+ # Purpose: to demonstrate that heart beats can work.
19
+ #
20
+ # Create connection headers
21
+ # =========================
22
+ #
23
+ conn_hdrs = {"accept-version" => "1.1", # 1.1
24
+ "host" => virt_host, # vhost
25
+ "heart-beat" => "5000,10000", # heartbeats
26
+ }
27
+ # Create a logger for demonstration purposes
28
+ logger = Slogger.new
29
+ # Connect
30
+ conn = Stomp::Connection.new(login, passcode, host, port, # Normal connect parms
31
+ false, # Not reliable, the default
32
+ 5, # Connect redelay, the default
33
+ conn_hdrs) # The 1.1 connection parameters
34
+ puts "Connection complete"
35
+ #
36
+ raise "Unexpected protocol level" if conn.protocol != Stomp::SPL_11
37
+ #
38
+ conn.set_logger(logger) # Connection uses a logger
39
+ sleep 65
40
+ conn.set_logger(nil) # No logging
41
+ #
42
+ conn.disconnect # Get out
43
+ puts "Disconnect complete"
44
+
45
+
46
+