modern_times 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.9
|
@@ -15,10 +15,10 @@ end
|
|
15
15
|
|
16
16
|
config = YAML.load(ERB.new(File.read(File.join(File.dirname(__FILE__), '..', 'jms.yml'))).result(binding))
|
17
17
|
ModernTimes::JMS::Connection.init(config)
|
18
|
-
publisher = ModernTimes::JMS::Publisher.new(:queue_name => 'Foo', :marshal => :string)
|
18
|
+
publisher = ModernTimes::JMS::Publisher.new(:queue_name => 'Foo', :marshal => :string, :time_to_live => 20000)
|
19
19
|
consumer = ModernTimes::JMS::Consumer.new(:queue_name => 'Foo', :marshal => :string)
|
20
20
|
|
21
21
|
publisher.publish(ARGV[0], :jms_correlation_id => ARGV[1])
|
22
|
-
msg = consumer.receive(:jms_correlation_id => ARGV[1], :timeout => 30000)
|
22
|
+
#msg = consumer.receive(:jms_correlation_id => ARGV[1], :timeout => 30000)
|
23
23
|
#msg = consumer.receive(:timeout => 1000)
|
24
|
-
puts "msg=#{msg}"
|
24
|
+
#puts "msg=#{msg}"
|
@@ -37,6 +37,7 @@ module ModernTimes
|
|
37
37
|
options[:selector] = "JMSCorrelationID = '#{correlation_id}'" if correlation_id && !options[:selector]
|
38
38
|
timeout = options.delete(:timeout) || 0
|
39
39
|
obj = nil
|
40
|
+
ModernTimes.logger.debug {"Perform receive for #{options.inspect} timeout=#{timeout}"}
|
40
41
|
|
41
42
|
Connection.session_pool.consumer(options) do |session, consumer|
|
42
43
|
message = consumer.get(:timeout => timeout)
|
@@ -32,12 +32,15 @@ module ModernTimes
|
|
32
32
|
#@persistent = options[:persistent] ? ::JMS::DeliveryMode::PERSISTENT : ::JMS::DeliveryMode::NON_PERSISTENT
|
33
33
|
@persistent = options[:persistent] ? :persistent : :non_persistent
|
34
34
|
@marshaler = ModernTimes::MarshalStrategy.find(options[:marshal])
|
35
|
+
@time_to_live = options[:time_to_live]
|
35
36
|
end
|
36
37
|
|
37
38
|
# Publish the given object to the address.
|
38
39
|
def publish(object, props={})
|
40
|
+
ModernTimes.logger.debug {"#{self}: Publishing #{object} with #{props.inspect}"}
|
39
41
|
message = nil
|
40
42
|
Connection.session_pool.producer(@real_producer_options) do |session, producer|
|
43
|
+
producer.time_to_live = @time_to_live if @time_to_live
|
41
44
|
message = ModernTimes::JMS.create_message(session, @marshaler, object)
|
42
45
|
message.jms_delivery_mode_sym = @persistent
|
43
46
|
props.each do |key, value|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
|
1
3
|
module ModernTimes
|
2
4
|
module JMS
|
3
5
|
|
@@ -108,9 +110,12 @@ module ModernTimes
|
|
108
110
|
ModernTimes.logger.debug "#{self}: Starting receive loop"
|
109
111
|
@status = nil
|
110
112
|
while msg = @consumer.receive
|
111
|
-
|
112
|
-
|
113
|
-
|
113
|
+
sec = Benchmark.realtime do
|
114
|
+
@message_count += 1
|
115
|
+
on_message(msg)
|
116
|
+
msg.acknowledge
|
117
|
+
end
|
118
|
+
ModernTimes.logger.info {"#{self}::perform (#{('%.1f' % (sec*1000))}ms)"}
|
114
119
|
end
|
115
120
|
@status = 'Exited'
|
116
121
|
ModernTimes.logger.info "#{self}: Exiting"
|
@@ -139,9 +144,9 @@ module ModernTimes
|
|
139
144
|
def on_message(message)
|
140
145
|
@message = message
|
141
146
|
object = @message_marshaler.unmarshal(message.data)
|
142
|
-
ModernTimes.logger.debug "#{self}: Received Object: #{object}"
|
147
|
+
ModernTimes.logger.debug {"#{self}: Received Object: #{object}"}
|
143
148
|
perform(object)
|
144
|
-
ModernTimes.logger.debug "#{self}: Finished processing message"
|
149
|
+
ModernTimes.logger.debug {"#{self}: Finished processing message"}
|
145
150
|
ModernTimes.logger.flush if ModernTimes.logger.respond_to?(:flush)
|
146
151
|
rescue Exception => e
|
147
152
|
ModernTimes.logger.error "#{self}: Messaging Exception: #{e.inspect}\n#{e.backtrace.inspect}"
|
@@ -5,7 +5,7 @@ module ModernTimes
|
|
5
5
|
module Railsable
|
6
6
|
def init_rails
|
7
7
|
# Allow user to use JMS w/o modifying jms.yml which could be checked in and hose other users
|
8
|
-
env = ENV['
|
8
|
+
env = ENV['MODERN_TIMES_ENV'] || Rails.env
|
9
9
|
if @config = YAML.load(ERB.new(File.read(File.join(Rails.root, "config", "jms.yml"))).result(binding))[env]
|
10
10
|
ModernTimes.logger.info "Messaging Enabled"
|
11
11
|
ModernTimes::JMS::Connection.init(@config)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: modern_times
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.9
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brad Pardee
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-05-
|
14
|
+
date: 2011-05-04 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|