explainer-rmb-rails 0.0.0 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -7,7 +7,8 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'logger'
10
- require 'rmb-rails'
10
+ require 'rmb'
11
+
11
12
 
12
13
  #
13
14
  # start the daemon worker code...
@@ -4,7 +4,9 @@ require 'rubygems'
4
4
  #
5
5
  require 'logger'
6
6
  require 'daemons'
7
- require 'rmb-rails'
7
+ require 'rmb'
8
+
9
+
8
10
  #
9
11
  # This ruby script is invoked by the ListenerClient.control method to start and stop the daemon
10
12
  #
data/lib/rmb-rails.rb CHANGED
@@ -1,51 +1,69 @@
1
- require 'stomp'
1
+ #
2
+ # = RESTful-Message-Beans module
3
+ #
4
+ # Abstraction which wraps the daemon scripts and
5
+ # handles the setup.
6
+ #
7
+ require 'listener_client'
8
+ require 'listener_main'
9
+ require 'mechanize_submitter'
10
+ require 'stomp_subscriber'
11
+ require 'submitter'
2
12
  require 'subscriber'
3
13
 
4
14
  module RMB
15
+ # This multi-level hash contains the initial set of properties needed to launch a Listener daemon.
16
+ #* Make a writable copy of this hash
17
+ #* Fill in the areas denoted by <<fill>> with your values
18
+ #* Add additional properties required by the Subscriber and Submitter classes used
19
+ #* Pass this has as the sole parameter in listener_client = ListenerClient.new(hash) to set up the daemon
20
+ #* Call listener_client.start to start the daemon.
21
+ RMB_Properties = {
22
+ :key => "<<fill>>",
23
+ :subscriber => {
24
+ :class_name => "<<fill>>" #set this to selected subclass of Subscriber
25
+ # <== add more properties for your Subscriber here
26
+ },
27
+ :submitter => {
28
+ :class_name => "<<fill>>" #set this to selected subclass of Submitter
29
+ # <== add more properties for your Submitter here
30
+ },
31
+ :working_dir => "<<fill>>", #set this to the RAILS_ROOT directory
32
+
33
+ :daemon_options => { #these options are passed directly to the class method Daemons.run(target, options)
34
+ :app_name => "", #custom name for this daemon, set by ListenerClient#setup
35
+ :ARGV => nil, #use the program defaults
36
+ :dir_mode => :normal, #requires absolute path
37
+ :dir => "<<fill>>", #this is set to "#{working_dir}/tmp/pids" by ListenerClient#setup
38
+ :multiple => false, #this will allow multiple daemons to run
39
+ :ontop => false, #
40
+ :mode => :load,
41
+ :backtrace => false,
42
+ :monitor => false,
43
+ :log_output => true,
44
+ :keep_pid_files => true,
45
+ :hard_exit => true
46
+ }
47
+ }
48
+
49
+ LD = "listener_daemon_" #prefix for all listener_daemon artifacts produced: pids, log files, property files, and message files
50
+
51
+ end
5
52
 
6
- class StompSubscriber < Subscriber
7
- attr_accessor :url, :host, :port, :user, :password, :connection, :logger
8
- =begin rdoc
9
- +connect+ Opens a connection with the message broker, and then subscribes on the url
10
- =end
11
- def connect
12
- super
13
- begin
14
- @connection = Stomp::Connection.open(user, password, host, port)
15
- @connection.subscribe url, { :ack => 'auto' }
16
- rescue Exception
17
- logger.fatal "#{__FILE__}:#{__LINE__} Exception #{$!}"
18
- raise
19
- end
20
- logger.info "Waiting for messages in #{url}."
21
- end
22
- =begin rdoc
23
- +properties=(hash)+ Accepts a hash object containing all of the configuration properties required. These properties are copied into instance variables.
24
- =end
25
- def properties=(hash)
26
- subscriber = hash[:subscriber]
27
- @url = subscriber[:url] || "/queue/something"
28
- @host = subscriber[:host] || ""
29
- @port = subscriber[:port] || 61613
30
- @user = subscriber[:user] || ""
31
- @password = subscriber[:password] || ""
32
- @connection = nil
33
- super
34
- end
35
- =begin rdoc
36
- +receive+ Executes a receive on the connection, thus blocking the daemon until a message arrives. Then answers the message.
37
- =end
38
- def receive
39
- super
40
- begin
41
- message = @connection.receive
42
- rescue Exception
43
- logger.fatal "#{__FILE__}:#{__LINE__} Exception #{$!}"
44
- raise
45
- end
46
- logger.info "Received message: #{message.inspect}"
47
- message
48
- end
49
- end
53
+ if __FILE__ == $0
54
+ hash = RMB::ListenerClient.properties('inventory', RAILS_ROOT, 'StompSubscriber', 'MechanizeSubmitter')
55
+ hash[:daemon_options][:dir] = File.join("#{hash[:working_dir]}", "tmp", "pids")
56
+ front = hash[:subscriber]
57
+ front[:url] = '/topic/inventory'
58
+ front[:host] = 'localhost'
59
+ front[:port] = 61613
60
+ front[:user] = nil
61
+ front[:password] = nil
50
62
 
63
+ back = hash[:submitter]
64
+ back[:login_url] = 'http://localhost:3000/login'
65
+ back[:delivery_url] = 'http://localhost:3000/documents/new'
66
+ lc = RMB::ListenerClient.new(hash)
67
+ puts lc.inspect
68
+ lc.start
51
69
  end
data/rmb-rails.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rmb-rails}
5
- s.version = "0.0.0"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ken Burgett"]
9
- s.date = %q{2009-07-21}
9
+ s.date = %q{2009-07-22}
10
10
  s.email = %q{keburgett@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -18,14 +18,13 @@ Gem::Specification.new do |s|
18
18
  "LICENSE",
19
19
  "README.rdoc",
20
20
  "Rakefile",
21
- "VERSION.yml",
21
+ "VERSION",
22
22
  "lib/listener_client.rb",
23
23
  "lib/listener_daemon.rb",
24
24
  "lib/listener_daemon_control.rb",
25
25
  "lib/listener_main.rb",
26
26
  "lib/mechanize_submitter.rb",
27
27
  "lib/rmb-rails.rb",
28
- "lib/rmb2.rb",
29
28
  "lib/stomp_subscriber.rb",
30
29
  "lib/submitter.rb",
31
30
  "lib/subscriber.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: explainer-rmb-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Burgett
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-21 00:00:00 -07:00
12
+ date: 2009-07-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -28,14 +28,13 @@ files:
28
28
  - LICENSE
29
29
  - README.rdoc
30
30
  - Rakefile
31
- - VERSION.yml
31
+ - VERSION
32
32
  - lib/listener_client.rb
33
33
  - lib/listener_daemon.rb
34
34
  - lib/listener_daemon_control.rb
35
35
  - lib/listener_main.rb
36
36
  - lib/mechanize_submitter.rb
37
37
  - lib/rmb-rails.rb
38
- - lib/rmb2.rb
39
38
  - lib/stomp_subscriber.rb
40
39
  - lib/submitter.rb
41
40
  - lib/subscriber.rb
data/lib/rmb2.rb DELETED
@@ -1,69 +0,0 @@
1
- #
2
- # = RESTful-Message-Beans module
3
- #
4
- # Abstraction which wraps the daemon scripts and
5
- # handles the setup.
6
- #
7
- require 'listener_client'
8
- require 'listener_main'
9
- require 'mechanize_submitter'
10
- require 'stomp_subscriber'
11
- require 'submitter'
12
- require 'subscriber'
13
-
14
- module RMB
15
- # This multi-level hash contains the initial set of properties needed to launch a Listener daemon.
16
- #* Make a writable copy of this hash
17
- #* Fill in the areas denoted by <<fill>> with your values
18
- #* Add additional properties required by the Subscriber and Submitter classes used
19
- #* Pass this has as the sole parameter in listener_client = ListenerClient.new(hash) to set up the daemon
20
- #* Call listener_client.start to start the daemon.
21
- RMB_Properties = {
22
- :key => "<<fill>>",
23
- :subscriber => {
24
- :class_name => "<<fill>>" #set this to selected subclass of Subscriber
25
- # <== add more properties for your Subscriber here
26
- },
27
- :submitter => {
28
- :class_name => "<<fill>>" #set this to selected subclass of Submitter
29
- # <== add more properties for your Submitter here
30
- },
31
- :working_dir => "<<fill>>", #set this to the RAILS_ROOT directory
32
-
33
- :daemon_options => { #these options are passed directly to the class method Daemons.run(target, options)
34
- :app_name => "", #custom name for this daemon, set by ListenerClient#initialize
35
- :ARGV => nil, #use the program defaults
36
- :dir_mode => :normal, #requires absolute path
37
- :dir => "<<fill>>", #this is set to "#{working_dir}/tmp/pids" by ListenerClient#setup
38
- :multiple => false, #this will allow multiple daemons to run
39
- :ontop => false, #
40
- :mode => :load,
41
- :backtrace => false,
42
- :monitor => false,
43
- :log_output => true,
44
- :keep_pid_files => true,
45
- :hard_exit => true
46
- }
47
- }
48
-
49
- LD = "listener_daemon_" #prefix for all listener_daemon artifacts produced: pids, log files, property files, and message files
50
-
51
- end
52
-
53
- if __FILE__ == $0
54
- hash = RMB::ListenerClient.properties('inventory', RAILS_ROOT, 'StompSubscriber', 'MechanizeSubmitter')
55
- hash[:daemon_options][:dir] = File.join("#{hash[:working_dir]}", "tmp", "pids")
56
- front = hash[:subscriber]
57
- front[:url] = '/topic/inventory'
58
- front[:host] = 'localhost'
59
- front[:port] = 61613
60
- front[:user] = nil
61
- front[:password] = nil
62
-
63
- back = hash[:submitter]
64
- back[:login_url] = 'http://localhost:3000/login'
65
- back[:delivery_url] = 'http://localhost:3000/documents/new'
66
- lc = RMB::ListenerClient.new(hash)
67
- puts lc.inspect
68
- lc.start
69
- end