stompserver_ng 1.0.6

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.
Files changed (72) hide show
  1. data/History.txt +159 -0
  2. data/Manifest.txt +71 -0
  3. data/README.txt +172 -0
  4. data/Rakefile +38 -0
  5. data/STATUS +5 -0
  6. data/bin/stompserver_ng +63 -0
  7. data/client/README.txt +1 -0
  8. data/client/both.rb +25 -0
  9. data/client/consume.rb +14 -0
  10. data/client/send.rb +17 -0
  11. data/config/stompserver_ng.conf +11 -0
  12. data/etc/19xcompat/notes.txt +223 -0
  13. data/etc/arutils/README-activerecord.txt +78 -0
  14. data/etc/arutils/cre_mysql.rb +34 -0
  15. data/etc/arutils/cre_postgres.rb +33 -0
  16. data/etc/arutils/cre_sqlite3.rb +28 -0
  17. data/etc/arutils/mysql_boot.sql +12 -0
  18. data/etc/arutils/postgres_boot.sql +14 -0
  19. data/etc/database.mysql.yml +9 -0
  20. data/etc/database.postgres.yml +9 -0
  21. data/etc/passwd.example +3 -0
  22. data/etc/ppqinfo.rb +15 -0
  23. data/etc/runserver.sh +17 -0
  24. data/etc/stompserver_ng +50 -0
  25. data/etc/stompserver_ng.conf +13 -0
  26. data/lib/stomp_server_ng.rb +471 -0
  27. data/lib/stomp_server_ng/protocols/http.rb +128 -0
  28. data/lib/stomp_server_ng/protocols/stomp.rb +407 -0
  29. data/lib/stomp_server_ng/qmonitor.rb +58 -0
  30. data/lib/stomp_server_ng/queue.rb +248 -0
  31. data/lib/stomp_server_ng/queue/activerecord_queue.rb +118 -0
  32. data/lib/stomp_server_ng/queue/ar_message.rb +21 -0
  33. data/lib/stomp_server_ng/queue/ar_reconnect.rb +18 -0
  34. data/lib/stomp_server_ng/queue/dbm_queue.rb +72 -0
  35. data/lib/stomp_server_ng/queue/file_queue.rb +56 -0
  36. data/lib/stomp_server_ng/queue/memory_queue.rb +64 -0
  37. data/lib/stomp_server_ng/queue_manager.rb +302 -0
  38. data/lib/stomp_server_ng/stomp_auth.rb +26 -0
  39. data/lib/stomp_server_ng/stomp_frame.rb +32 -0
  40. data/lib/stomp_server_ng/stomp_frame_recognizer.rb +77 -0
  41. data/lib/stomp_server_ng/stomp_id.rb +32 -0
  42. data/lib/stomp_server_ng/stomp_user.rb +17 -0
  43. data/lib/stomp_server_ng/test_server.rb +21 -0
  44. data/lib/stomp_server_ng/topic_manager.rb +46 -0
  45. data/setup.rb +1585 -0
  46. data/stompserver_ng.gemspec +136 -0
  47. data/test/devserver/props.yaml +5 -0
  48. data/test/devserver/runserver.sh +16 -0
  49. data/test/devserver/stompserver_ng.dbm.conf +12 -0
  50. data/test/devserver/stompserver_ng.file.conf +12 -0
  51. data/test/devserver/stompserver_ng.memory.conf +12 -0
  52. data/test/noserver/mocklogger.rb +12 -0
  53. data/test/noserver/test_queue_manager.rb +134 -0
  54. data/test/noserver/test_stomp_frame.rb +138 -0
  55. data/test/noserver/test_topic_manager.rb +79 -0
  56. data/test/noserver/ts_all_no_server.rb +12 -0
  57. data/test/props.yaml +5 -0
  58. data/test/runalltests.sh +14 -0
  59. data/test/runtest.sh +4 -0
  60. data/test/test_0000_base.rb +107 -0
  61. data/test/test_0001_conn.rb +47 -0
  62. data/test/test_0002_conn_sr.rb +94 -0
  63. data/test/test_0006_client.rb +41 -0
  64. data/test/test_0011_send_recv.rb +74 -0
  65. data/test/test_0015_ack_conn.rb +78 -0
  66. data/test/test_0017_ack_client.rb +78 -0
  67. data/test/test_0019_ack_no_ack.rb +145 -0
  68. data/test/test_0022_ack_noack_conn.rb +123 -0
  69. data/test/test_0030_subscr_id.rb +44 -0
  70. data/test/test_0040_receipt_conn.rb +87 -0
  71. data/test/ts_all_server.rb +10 -0
  72. metadata +196 -0
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'etc'
4
+ require 'yaml'
5
+ require 'daemons/daemonize'
6
+ require 'stomp_server_ng'
7
+ require 'optparse'
8
+ require 'logger'
9
+
10
+ $STOMP_SERVER = true
11
+
12
+ $HTTP_ENABLE = false
13
+ if $HTTP_ENABLE
14
+ require 'mongrel'
15
+ require 'stomp_server/protocols/http'
16
+ end
17
+ #
18
+ # Use epoll if available.
19
+ #
20
+ EventMachine::epoll
21
+ #
22
+ # Run.
23
+ #
24
+ EventMachine::run do
25
+
26
+ ## Get the configuration and initialize the stomp engine
27
+ config = StompServer::Configurator.new
28
+ stomp = StompServer::Run.new(config.opts)
29
+ stomp.start
30
+
31
+ log = Logger.new(STDOUT)
32
+ log.level = Logger::DEBUG
33
+
34
+ # Might want to uncomment this if you are sending large files
35
+ #EventMachine::add_periodic_timer 10, proc {GC.start}
36
+
37
+ log.debug "Client authorization enabled" if config.opts[:auth]
38
+
39
+ ## Start protocol handlers
40
+
41
+ log.debug "Stomp protocol handler starting on #{config.opts[:host]} port #{config.opts[:port]}"
42
+ EventMachine.start_server(config.opts[:host],
43
+ config.opts[:port],
44
+ StompServer::Protocols::Stomp,
45
+ stomp.auth_required, # *args: arg[0]
46
+ stomp.queue_manager, # *args: arg[1]
47
+ stomp.topic_manager, # *args: arg[2]
48
+ stomp.stompauth, # *args: arg[3]
49
+ config.opts # Options hash
50
+ )
51
+
52
+ # TODO: any http testing and protocol handler changes required.
53
+ if $HTTP_ENABLE
54
+ log.debug "Http protocol handler starting on #{config.opts[:host]} port 8080"
55
+ EventMachine.start_server(config.opts[:host], 8080, StompServer::Protocols::Http) {|s| s.instance_eval {
56
+ @@auth_required=stomp.auth_required
57
+ @@queue_manager=stomp.queue_manager
58
+ @@topic_manager=stomp.topic_manager
59
+ @@stompauth = stomp.stompauth
60
+ }
61
+ }
62
+ end
63
+ end
@@ -0,0 +1 @@
1
+ Samples of how to use the ruby stomp client with stompserver
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'stomp'
3
+ client = Stomp::Client.open "login", "passcode", "localhost", 61613
4
+
5
+ client.subscribe("/queue/client2", {
6
+ "persistent" => true,
7
+ "ack" => 'client',
8
+ "client-id" => "rubyClient",
9
+ } ) do |message|
10
+ puts "Got Reply: #{message.headers['message-id']} - #{message.body} on #{message.headers['destination']}"
11
+ end
12
+
13
+ for i in 1..5 do
14
+ m = "Go Sox #{i}!"
15
+ puts m
16
+ client.send("/queue/client2", m, {
17
+ "persistent" => true,
18
+ "priority" => 4,
19
+ "reply-to" => "/queue/client2",
20
+ }
21
+ )
22
+ end
23
+
24
+ gets
25
+ client.close
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'stomp'
3
+ client = Stomp::Client.open "login", "passcode", "localhost", 61613
4
+
5
+ client.subscribe("/queue/test", {
6
+ "persistent" => true,
7
+ "client-id" => "rubyClient",
8
+ } ) do |message|
9
+ puts "Got Reply: ID=#{message.headers['message-id']} BODY=#{message.body} on #{message.headers['destination']}"
10
+ end
11
+
12
+
13
+ gets
14
+ client.close
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'stomp'
3
+ client = Stomp::Client.open "login", "passcode", "localhost", 61613
4
+
5
+ # sending 5 messages at once
6
+ for i in 1..5 do
7
+ m = "Go Sox #{i}!"
8
+ puts m
9
+ client.send("/queue/test", m, {
10
+ "persistent" => true,
11
+ "client-id" => "Client1",
12
+ "reply-to" => "/queue/test",
13
+ }
14
+ )
15
+ end
16
+
17
+ client.close
@@ -0,0 +1,11 @@
1
+ ---
2
+ :daemon: false
3
+ :working_dir: /tmp/stompserver
4
+ :storage: .queue
5
+ :queue: file
6
+ :auth: false
7
+ :debug: false
8
+ :group:
9
+ :user:
10
+ :host: 127.0.0.1
11
+ :port: 61613
@@ -0,0 +1,223 @@
1
+ #
2
+ # == Ruby 1.9.x Testing Activities Log
3
+ #
4
+ # The reader should absorb this sequentially. The text is a rough
5
+ # chronological depiction of events for these activities.
6
+ #
7
+ # === Assumptions
8
+ #
9
+ # * $PH=project_home_directory
10
+ # * Commands are issued from the project home directory
11
+ # * No attempt is made to support 'tesly' functionality
12
+ #
13
+ # === Server Start
14
+ #
15
+ # * Modify $PH/test/runserver.sh as required
16
+ # * ./test/runserver.sh
17
+ #
18
+ # === Verify/Deny Existing Tests Functionality
19
+ #
20
+ # Verify/deny that the existing tests run. These are:
21
+ #
22
+ # ==== $PH/test/test_queue_manager.rb
23
+ #
24
+ # To execute use one of these commands:
25
+ #
26
+ # * ./test/runtest.sh test/test_queue_manager.rb
27
+ # * ruby -I $(pwd)/lib test/test_queue_manager.rb
28
+ #
29
+ # ==== $PH/test/test_stomp_frame.rb
30
+ #
31
+ # To execute use one of these commands:
32
+ #
33
+ # * ./test/runtest.sh test/test_stomp_frame.rb
34
+ # * ruby -I $(pwd)/lib test/test_stomp_frame.rb
35
+ #
36
+ # ==== $PH/test/test_topic_manager.rb
37
+ #
38
+ # To execute use one of these commands:
39
+ #
40
+ # * ./test/runtest.sh test/test_topic_manager.rb
41
+ # * ruby -I $(pwd)/lib test/test_topic_manager.rb
42
+ #
43
+ # ==== Results
44
+ #
45
+ # Note: first verify that these actually run under
46
+ # ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]. They do.
47
+ #
48
+ # All three of these tests encountered errors with
49
+ # ruby 1.9.1p243 (2009-07-16 revision 24175) [i486-linux].
50
+ #
51
+ # * test_queue_manager.rb
52
+ # ** TypeError: can't convert Fixnum into String
53
+ # ** lib/stomp_server/stomp_frame.rb:13:in `include?'
54
+ # * test_stomp_frame.rb
55
+ # ** TypeError: type mismatch: Fixnum given
56
+ # ** lib/stomp_server/stomp_frame.rb:54:in `index'
57
+ # * test_topic_manager.rb
58
+ # ** test_sendmsg(TestTopics):
59
+ # ** ArgumentError: wrong number of arguments (0 for 1)
60
+ #
61
+ # ==== Fixes
62
+ #
63
+ # <b>test_queue_manager</b>
64
+ #
65
+ # * Added logging to the test
66
+ # * Changes to stomp_frame.rb to properly compare single characters or locate single characters in a string.
67
+ #
68
+ # <b>test_stomp_frame</b>
69
+ #
70
+ # * Added logging to the test
71
+ # * Changes to stomp_frame.rb to properly compare single characters or locate single characters in a string.
72
+ #
73
+ # <b>test_topic_manager</b>
74
+ #
75
+ # * Added logging to the test
76
+ # * Remove unused and unrequired method parameter
77
+ #
78
+ # -----
79
+ #
80
+ # During the attempt to add robust logging to the server code, it was
81
+ # eventaully recognized that:
82
+ #
83
+ # * the existing tests do not even require a stompserver to be running
84
+ # * some experimental but sound logging code then broke even existing tests with ruby 1.8
85
+ #
86
+ # Why the breakage? Because the existing tests do not use a running server,
87
+ # instead including portions of server code.
88
+ #
89
+ # This leads to the following sections.
90
+ #
91
+ # == Logging Using Standard Ruby 'logger'
92
+ #
93
+ # Initial attempts to implement this across the framework broke horribly.
94
+ # Additionally, even the existing tests failed under ruby 1.8.
95
+ #
96
+ # The initial goal of this phase was to execute the existing tests with:
97
+ #
98
+ # * Initial changes to the framework required for adding logging.
99
+ # * Successful test execution under ruby 1.8.
100
+ #
101
+ # This phase of changes was eventually completed.
102
+ #
103
+ # == Existing Tests and Ruby Version Compatability Summary
104
+ #
105
+ # After the work described briefly above, the existing tests function on:
106
+ #
107
+ # * ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
108
+ # * ruby 1.9.0 (2008-10-04 revision 19669) [i486-linux]
109
+ # * ruby 1.9.1p243 (2009-07-16 revision 24175) [i486-linux]
110
+ #
111
+ # Again, note that these tests do _not_ use a running stompserver, but
112
+ # use mock objects to drive the testing.
113
+ #
114
+ # == Further Testing
115
+ #
116
+ # This section describes further testing of the stompserver framework.
117
+ #
118
+ # The requirements for running the tests described here are:
119
+ #
120
+ # * a running instance of a stompserver
121
+ # * the server host and port match those specified in <b>props.yaml</b>
122
+ #
123
+ # === Connect and Disconnect Processing
124
+ #
125
+ # Run the following test:
126
+ #
127
+ # * ruby test/test_0001_conn.rb
128
+ #
129
+ # === Connect and Disconnect With Send and Receive
130
+ #
131
+ # Run the following test:
132
+ #
133
+ # * ruby test/test_0002_conn_sr.rb
134
+ #
135
+ # === Stomp Client Creation
136
+ #
137
+ # Run the following test:
138
+ #
139
+ # * ruby test/test_0006_client.rb
140
+ #
141
+ # === Basic Send / Receive Test
142
+ #
143
+ # Run the following test:
144
+ #
145
+ # * ruby test/test_0011_send_recv.rb
146
+ #
147
+ # === Informal Client Testing
148
+ #
149
+ # Informal testing using the code at git://github.com/gmallard/stomp-demo.git
150
+ # indicate that the server basically functions using ruby 1.9.1.
151
+ #
152
+ # == Gem Build
153
+ #
154
+ # The gem build process now works, after fixing the _Rakefile_ properly.
155
+ #
156
+ # The _stompserver.gemspec_ file has been updated to use Hoe::spec rather
157
+ # than Hoe::new, per deprecation warnings.
158
+ #
159
+ # To generate a new gemspec file use:
160
+ #
161
+ # * rake debug_gem > stompserver.gemspec
162
+ #
163
+ # To generate the gem use:
164
+ #
165
+ # * rake gem
166
+ #
167
+ # === Gem Todo List
168
+ #
169
+ # Installs on all local ruby versions is complete, with VERSION
170
+ # 0.9.9.2009.12.21.00.
171
+ #
172
+ # == More Test Information
173
+ #
174
+ # === Tests Which Require a Server
175
+ #
176
+ # * ruby test/ts_all_server.rb
177
+ #
178
+ # === Tests Which No Not Require a Server
179
+ #
180
+ # When running these tests it is <b>important</b> to use the
181
+ # '-I $(pwd)/lib' ruby parameter. This insures that local code
182
+ # only will be used for the tests.
183
+ #
184
+ # * ruby -I $(pwd)/lib test/ts_all_no_server.rb
185
+ #
186
+ # == Todo List
187
+ #
188
+ # * More unit tests (in progress)
189
+ # * More documentation (in progress)
190
+ # * Build gem (see above) :DONE
191
+ # * Install gem (see above) :DONE
192
+ # * Full testing using 1.9.0 :DONE
193
+ # * Full regression testing using 1.8.7 :DONE
194
+ # * Everyting with the HTTP protocol handler.
195
+ #
196
+ # == Required Gems
197
+ #
198
+ # Required gems are:
199
+ #
200
+ # * ["daemons", ">= 1.0.10"]
201
+ # * ["eventmachine", ">= 0.12.10"]
202
+ # * ["hoe", ">= 2.3.2"]
203
+ # * ["uuid", ">= 2.1.0"]
204
+ #
205
+ # == Version 0.9.9.2010.01.01.00
206
+ #
207
+ # * Some fixes for 'ack' => 'client' processing. The first step down this road.
208
+ # * Tests for same. Tests are intermittently unstable due to previously unseen problems.
209
+ # * Some fixes around session ID cache handling.
210
+ # * Cleaner creation of the .pid file at startup.
211
+ # * Sample sysvinit boot scripts - very primitive.
212
+ #
213
+ # == Version 0.9.9.2010.01.02.00
214
+ #
215
+ # * Fix server crashes when no ACK received.
216
+ # * Tests for same.
217
+ # * Handle SIGTERM.
218
+ #
219
+ # == Future Updates
220
+ #
221
+ # For updates after the previous version see the History.txt file.
222
+ #
223
+
@@ -0,0 +1,78 @@
1
+
2
+ = Activerecord Notes
3
+
4
+ == Current Support
5
+
6
+ Support is provided activerecord messages stores using:
7
+
8
+ * sqlite3
9
+ * mysql
10
+ * postgresql
11
+
12
+ == Using An Activerecord Message Store
13
+
14
+ In order to use activerecord, you _must_ preinitialize:
15
+
16
+ * a data base
17
+ * a data base user
18
+ * a table named 'ar_messages'
19
+
20
+ Samples are provided with the stompserver_ng installation.
21
+
22
+ See:
23
+
24
+ * this document
25
+ * etc/arutils/mysql_boot.sql
26
+ * etc/arutils/postgres_boot.sql
27
+ * etc/arutils/cre_sqlite3.rb
28
+ * etc/arutils/cre_mysql.rb
29
+ * etc/arutils/cre_postgres.rb
30
+
31
+ To use either mysql or postgres, you must supply a user coded connection
32
+ definition in a yaml file. This file has the same format as db definitions
33
+ in Rails projects.
34
+
35
+ You can specify activerecord use by either:
36
+
37
+ * the main stompserver_ng configuration file
38
+ * :queue: activerecord
39
+ * command line option when stompserver_ng starts
40
+ * -q activerecord
41
+ * --queuetype=activerecord
42
+
43
+ == Default Activerecord Environment
44
+
45
+ If an activerecord message store is specified by configuration, and no
46
+ overriding connection parameters are specified, the default implementation
47
+ is sqlite3. (Note: even in this case, the data base must be predefined and
48
+ initialized.)
49
+
50
+ The default sqlite3 data base must:
51
+
52
+ * exist in the runtime 'etc' directory
53
+ * be named 'stompserver_development'
54
+
55
+ == Overriding Connection Parameters
56
+
57
+ Override connection parameters in order to use a data base other than
58
+ the default.
59
+
60
+ You can override activerecord connection parameters by either:
61
+
62
+ * the main stompserver_ng configuration file
63
+ * :dbyml: some/directory/mydb.yml
64
+ * command line option when stompserver_ng starts
65
+ * -y some/directory/mydb.yml
66
+ * --dbyml=some/directory/mydb.yml
67
+
68
+ == Activerecord Support
69
+
70
+ stompserver_ng has been tested with:
71
+
72
+ * sqlite3
73
+ * mysql
74
+ * postgresql
75
+
76
+ Support for other database systems used by activerecord is left as an
77
+ exercise for the reader.
78
+
@@ -0,0 +1,34 @@
1
+ require 'rubygems' if RUBY_VERSION =~ /1.8/
2
+ require 'active_record'
3
+ #
4
+ # = cre_mysql - create a mysql data base for use by stompserver_ng
5
+ #
6
+ # For now, the db parameters are hard coded. Change as required.
7
+ #
8
+ db_params = {
9
+ 'adapter' => 'mysql',
10
+ 'encoding' => 'utf8',
11
+ 'database' => 'ssng_dev',
12
+ 'pool' => 5,
13
+ 'username' => 'ssng',
14
+ 'password' => 'xxxxxxxx',
15
+ 'host' => 'localhost',
16
+ 'port' => 3306
17
+
18
+ }
19
+ #
20
+ # Connect.
21
+ #
22
+ ActiveRecord::Base.establish_connection(db_params)
23
+ puts "mysql Connection complete."
24
+ #
25
+ # Define the ar_messages table.
26
+ #
27
+ ActiveRecord::Schema.define do
28
+ create_table 'ar_messages' do |t|
29
+ t.column 'stomp_id', :string, :null => false
30
+ t.column 'frame', :text, :null => false
31
+ end
32
+ end
33
+ puts "mysql table create complete."
34
+