eventbus 0.27 → 0.28
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/lib/eventbus/connectors/stomp.rb +4 -6
- data/lib/eventbus/message.rb +1 -1
- data/lib/eventbus/service.rb +21 -19
- metadata +2 -2
@@ -6,8 +6,6 @@ require 'socket'
|
|
6
6
|
require 'stomp'
|
7
7
|
module StompConnectionDriver
|
8
8
|
|
9
|
-
@@StompConnector_Connection = nil
|
10
|
-
|
11
9
|
def connection_driver_initialize
|
12
10
|
|
13
11
|
end
|
@@ -76,15 +74,15 @@ module StompConnectionDriver
|
|
76
74
|
}
|
77
75
|
|
78
76
|
# If we never opened one, or if it's closed and not reliable, then open a new connection.
|
79
|
-
if
|
77
|
+
if Thread.current[:stomp_connection].nil? || (Thread.current[:stomp_connection].closed? && ! Thread.current[:stomp_connection].reliable?)
|
80
78
|
EventBus.logger.info("Connecting to STOMP with options: #{opts.to_s}")
|
81
|
-
|
79
|
+
Thread.current[:stomp_connection] = Stomp::Client.new(opts)
|
82
80
|
end
|
83
81
|
|
84
82
|
# I'm not sure whether we should sleep here if the connection is closed?() but is reliable?()
|
85
83
|
# Assuming that the connection will do the right thing and punting until I find out different.
|
86
84
|
|
87
|
-
return
|
85
|
+
return Thread.current[:stomp_connection]
|
88
86
|
|
89
87
|
end
|
90
88
|
|
@@ -125,7 +123,7 @@ module StompConnectionDriver
|
|
125
123
|
# and only take blocks of one message rather than claiming large blocks. These assumptions should become
|
126
124
|
# configurable at some point, but for now it's not really a concern.
|
127
125
|
|
128
|
-
client.subscribe(queue_name, {"activemq.prefetchSize" => 1,
|
126
|
+
client.subscribe(queue_name, {"activemq.prefetchSize".to_sym => 1, :exclusive => "false"}) do |msg|
|
129
127
|
yield msg.body
|
130
128
|
end
|
131
129
|
|
data/lib/eventbus/message.rb
CHANGED
data/lib/eventbus/service.rb
CHANGED
@@ -49,32 +49,34 @@ class Service
|
|
49
49
|
def start ( opts = {} )
|
50
50
|
|
51
51
|
max_workers = opts.delete(:max_workers) || 5
|
52
|
+
async_service = opts.delete(:async_service) || false
|
52
53
|
|
53
54
|
opts[:system_queue] = @system_process
|
54
55
|
opts[:global_process] = @global_process
|
55
56
|
|
56
57
|
queue_name = Queue.calc_name(listen_queue, @application_id, EventBus.PROD_LEVEL, opts)
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
59
|
+
# I tried to have a single connection dole out to a worker pool, but I was having
|
60
|
+
# weird issues which I think were due to race conditions on the broker connections.
|
61
|
+
# Just spin off threads prior to starting connections so every thread has a private
|
62
|
+
# connection.
|
63
|
+
|
64
|
+
(1..max_workers).each do
|
65
|
+
Thread.new {
|
66
|
+
watch_queue(queue_name) do |message|
|
67
|
+
process_message_wrapper message
|
68
|
+
end
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
# If async_service is false, we'll
|
73
|
+
# just return and leave it up to the caller to not
|
74
|
+
# exit too soon.
|
75
|
+
|
76
|
+
unless async_service
|
77
|
+
loop do
|
78
|
+
sleep 6000
|
71
79
|
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
# Just sleep in the main thread. Nothing going on here anymore.
|
76
|
-
loop do
|
77
|
-
sleep 6000
|
78
80
|
end
|
79
81
|
|
80
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventbus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.28'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amqp
|