modern_times 0.3.10 → 0.3.11
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.
- data/History.md +5 -0
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/modern_times/jms/publisher.rb +28 -26
- data/lib/modern_times/railsable.rb +14 -5
- metadata +14 -5
data/History.md
CHANGED
data/Rakefile
CHANGED
@@ -13,6 +13,7 @@ begin
|
|
13
13
|
gemspec.homepage = 'http://github.com/ClarityServices/modern_times'
|
14
14
|
gemspec.add_dependency 'jruby-jms', ['>= 0.11.2']
|
15
15
|
gemspec.add_dependency 'jmx', ['>= 0.6']
|
16
|
+
gemspec.add_dependency 'gene_pool'
|
16
17
|
end
|
17
18
|
rescue LoadError
|
18
19
|
puts 'Jeweler not available. Install it with: gem install jeweler'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.11
|
@@ -82,30 +82,32 @@ module ModernTimes
|
|
82
82
|
dummy_handle = PublishHandle.new(self, nil, Time.now)
|
83
83
|
# Model real queue marshaling/unmarshaling
|
84
84
|
trans_object = @marshaler.unmarshal(@marshaler.marshal(object))
|
85
|
-
@@
|
86
|
-
|
87
|
-
if
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
85
|
+
@@worker_pools.each do |worker_pool|
|
86
|
+
worker_pool.with_connection do |worker|
|
87
|
+
if ModernTimes::JMS.same_destination?(@producer_options, worker.destination_options)
|
88
|
+
if worker.kind_of?(RequestWorker)
|
89
|
+
ModernTimes.logger.debug "Dummy request publishing #{trans_object} to #{worker}"
|
90
|
+
m = worker.marshaler
|
91
|
+
# Model real queue marshaling/unmarshaling
|
92
|
+
begin
|
93
|
+
response_object = m.unmarshal(m.marshal(worker.request(trans_object)))
|
94
|
+
dummy_handle.add_dummy_response(worker.name, response_object)
|
95
|
+
rescue Exception => e
|
96
|
+
ModernTimes.logger.error("#{worker} Exception: #{e.message}\n\t#{e.backtrace.join("\n\t")}")
|
97
|
+
dummy_handle.add_dummy_response(worker.name, ModernTimes::RemoteException.new(e))
|
98
|
+
end
|
99
|
+
begin
|
100
|
+
worker.post_request(trans_object)
|
101
|
+
rescue Exception => e
|
102
|
+
ModernTimes.logger.error("#{worker} Exception in post_request: #{e.message}\n\t#{e.backtrace.join("\n\t")}")
|
103
|
+
end
|
104
|
+
elsif worker.kind_of?(Worker)
|
105
|
+
ModernTimes.logger.debug "Dummy publishing #{trans_object} to #{worker}"
|
106
|
+
begin
|
107
|
+
worker.perform(trans_object)
|
108
|
+
rescue Exception => e
|
109
|
+
ModernTimes.logger.error("#{worker} Exception: #{e.message}\n\t#{e.backtrace.join("\n\t")}")
|
110
|
+
end
|
109
111
|
end
|
110
112
|
end
|
111
113
|
end
|
@@ -117,9 +119,9 @@ module ModernTimes
|
|
117
119
|
"#{self.class.name}:#{@real_producer_options.inspect}"
|
118
120
|
end
|
119
121
|
|
120
|
-
def self.setup_dummy_publishing(
|
122
|
+
def self.setup_dummy_publishing(worker_pools)
|
121
123
|
@@dummy_publishing = true
|
122
|
-
@@
|
124
|
+
@@worker_pools = worker_pools
|
123
125
|
alias_method :real_publish, :publish
|
124
126
|
alias_method :publish, :dummy_publish
|
125
127
|
PublishHandle.setup_dummy_handling
|
@@ -41,13 +41,22 @@ module ModernTimes
|
|
41
41
|
Rails.logger.info "Messaging disabled"
|
42
42
|
@is_jms_enabled = false
|
43
43
|
worker_file = File.join(Rails.root, "config", "workers.yml")
|
44
|
-
|
44
|
+
worker_pools = []
|
45
45
|
ModernTimes::Manager.parse_worker_file(worker_file, @env) do |klass, count, options|
|
46
|
-
|
46
|
+
# Create a pool for each worker so a single instance won't have to be thread safe when multiple http request hit it concurrently.
|
47
|
+
worker_pools << GenePool.new(:pool_size => count, :logger => Rails.logger) do
|
48
|
+
klass.new(options)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
# If no config, then just create a worker_pool for each class in the app/workers directory
|
52
|
+
if worker_pools.empty?
|
53
|
+
worker_pools = rails_workers.map do |klass|
|
54
|
+
GenePool.new(:pool_size => 1, :logger => Rails.logger) do
|
55
|
+
klass.new({})
|
56
|
+
end
|
57
|
+
end
|
47
58
|
end
|
48
|
-
|
49
|
-
workers = rails_workers.map {|klass| klass.new({})} if workers.empty?
|
50
|
-
ModernTimes::JMS::Publisher.setup_dummy_publishing(workers)
|
59
|
+
ModernTimes::JMS::Publisher.setup_dummy_publishing(worker_pools)
|
51
60
|
end
|
52
61
|
end
|
53
62
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: modern_times
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.11
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brad Pardee
|
@@ -11,8 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-
|
15
|
-
default_executable:
|
14
|
+
date: 2011-11-08 00:00:00 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: jruby-jms
|
@@ -36,6 +35,17 @@ dependencies:
|
|
36
35
|
version: "0.6"
|
37
36
|
type: :runtime
|
38
37
|
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: gene_pool
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id003
|
39
49
|
description: Generic asynchronous task library
|
40
50
|
email:
|
41
51
|
- bradpardee@gmail.com
|
@@ -110,7 +120,6 @@ files:
|
|
110
120
|
- test/jms_requestor_test.rb
|
111
121
|
- test/jms_test.rb
|
112
122
|
- test/marshal_strategy_test.rb
|
113
|
-
has_rdoc: true
|
114
123
|
homepage: http://github.com/ClarityServices/modern_times
|
115
124
|
licenses: []
|
116
125
|
|
@@ -134,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
143
|
requirements: []
|
135
144
|
|
136
145
|
rubyforge_project:
|
137
|
-
rubygems_version: 1.
|
146
|
+
rubygems_version: 1.8.9
|
138
147
|
signing_key:
|
139
148
|
specification_version: 3
|
140
149
|
summary: Asynchronous task library
|