rservicebus 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -25
- data/lib/rservicebus.rb +1 -0
- data/lib/rservicebus/AppResource/Mysql.rb +28 -0
- data/lib/rservicebus/Config.rb +2 -1
- data/lib/rservicebus/ConfigureAppResource.rb +28 -25
- data/lib/rservicebus/Host.rb +19 -4
- data/lib/rservicebus/Test/Redis.rb +5 -0
- metadata +3 -2
data/README.md
CHANGED
@@ -7,26 +7,7 @@ A Ruby interpretation of NServiceBus
|
|
7
7
|
*Dont solve infrastructure problems with software
|
8
8
|
*Infrastructure in this case refers to anything not specific to the application domain
|
9
9
|
|
10
|
-
##Points of view in the framework
|
11
|
-
* Bus
|
12
|
-
* Handler
|
13
|
-
* Client
|
14
|
-
|
15
|
-
#Platform
|
16
|
-
* Messages
|
17
|
-
* MessageHandler
|
18
|
-
* MessageHandling
|
19
|
-
* Queues
|
20
|
-
* Transport
|
21
|
-
* Transactions
|
22
|
-
|
23
|
-
##Message
|
24
|
-
* Yaml
|
25
|
-
* Unique Message ID's
|
26
|
-
|
27
10
|
##Queues
|
28
|
-
* Durable
|
29
|
-
* Store & Forward
|
30
11
|
* Queues specified by config, determined by message type
|
31
12
|
|
32
13
|
##Transport
|
@@ -38,9 +19,3 @@ A Ruby interpretation of NServiceBus
|
|
38
19
|
* Multiple handlers for message are in files under top level directory
|
39
20
|
* Handlers are dynamically loaded
|
40
21
|
* If a handler fails to load, the service wont start - infrastructure problem
|
41
|
-
|
42
|
-
##MessageHandling
|
43
|
-
* Transactions are good, use them
|
44
|
-
* Given transactions, the first thing to do on error is retry
|
45
|
-
* Once we've used up retry, put the message on an error queue to process later - it's a logic problem
|
46
|
-
|
data/lib/rservicebus.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
module RServiceBus
|
2
|
+
|
3
|
+
require "mysql2"
|
4
|
+
|
5
|
+
#Implementation of an AppResource - Redis
|
6
|
+
class AppResource_Mysql<AppResource
|
7
|
+
|
8
|
+
@connection
|
9
|
+
|
10
|
+
def initialize( uri )
|
11
|
+
super(uri)
|
12
|
+
host = uri.host
|
13
|
+
database = uri.path.sub( "/", "" )
|
14
|
+
|
15
|
+
|
16
|
+
@connection = Mysql2::Client.new(:host => uri.host,
|
17
|
+
:database => uri.path.sub( "/", "" ),
|
18
|
+
:username => uri.user )
|
19
|
+
puts "AppResource_Mysql. Connected to, " + uri.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def getResource
|
23
|
+
return @connection
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/rservicebus/Config.rb
CHANGED
@@ -2,7 +2,7 @@ module RServiceBus
|
|
2
2
|
|
3
3
|
#Marshals configuration information for an rservicebus host
|
4
4
|
class Config
|
5
|
-
attr_reader :appName, :messageEndpointMappings, :handlerPathList, :localQueueName, :errorQueueName, :maxRetries, :forwardReceivedMessagesTo, :verbose, :beanstalkHost, :queueTimeout
|
5
|
+
attr_reader :appName, :messageEndpointMappings, :handlerPathList, :localQueueName, :errorQueueName, :maxRetries, :forwardReceivedMessagesTo, :verbose, :beanstalkHost, :queueTimeout, :statOutputCountdown
|
6
6
|
|
7
7
|
@appName
|
8
8
|
@messageEndpointMappings
|
@@ -88,6 +88,7 @@ class Config
|
|
88
88
|
@maxRetries = self.getValue( "MAX_RETRIES", "5" ).to_i
|
89
89
|
@forwardReceivedMessagesTo = self.getValue( "FORWARD_RECEIVED_MESSAGES_TO" )
|
90
90
|
@queueTimeout = self.getValue( "QUEUE_TIMEOUT", "5" ).to_i
|
91
|
+
@statOutputCountdown = self.getValue( "STAT_OUTPUT_COUNTDOWN", "100" ).to_i
|
91
92
|
|
92
93
|
return self
|
93
94
|
end
|
@@ -1,30 +1,33 @@
|
|
1
1
|
module RServiceBus
|
2
|
-
|
3
|
-
require "uri"
|
4
|
-
|
5
|
-
#Configure AppResources for an rservicebus host
|
6
|
-
class ConfigureAppResource
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
#Configure AppResources for an rservicebus host
|
6
|
+
class ConfigureAppResource
|
7
|
+
|
8
|
+
def getResources( env )
|
9
|
+
resources = Hash.new
|
10
|
+
|
11
|
+
env.each do |k,v|
|
12
|
+
if v.is_a?(String) and
|
13
13
|
k.start_with?( "RSB_" ) then
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
uri = URI.parse( v )
|
15
|
+
case uri.scheme
|
16
|
+
when "redis"
|
17
17
|
resources[k.sub( "RSB_", "" )] = AppResource_Redis.new( uri )
|
18
|
-
|
18
|
+
|
19
|
+
when "mysql"
|
20
|
+
resources[k.sub( "RSB_", "" )] = AppResource_Mysql.new( uri )
|
21
|
+
else
|
19
22
|
abort("Scheme, #{uri.scheme}, not recognised when configuring app resource, #{k}=#{v}");
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
return resources
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
30
33
|
end
|
data/lib/rservicebus/Host.rb
CHANGED
@@ -130,12 +130,19 @@ class Host
|
|
130
130
|
# - Most of this should be queue independant
|
131
131
|
def StartListeningToEndpoints
|
132
132
|
log "Waiting for messages. To exit press CTRL+C"
|
133
|
+
statOutputCountdown = 0
|
134
|
+
messageLoop = true
|
133
135
|
|
134
|
-
|
136
|
+
while messageLoop do
|
135
137
|
retries = @config.maxRetries
|
136
138
|
#Popping a msg off the queue should not be in the message handler, as it affects retry
|
137
139
|
begin
|
138
|
-
|
140
|
+
if statOutputCountdown == 0 then
|
141
|
+
log @stats.getForReporting
|
142
|
+
statOutputCountdown = @config.statOutputCountdown-1
|
143
|
+
else
|
144
|
+
statOutputCountdown = statOutputCountdown - 1
|
145
|
+
end
|
139
146
|
job = @beanstalk.reserve @config.queueTimeout
|
140
147
|
begin
|
141
148
|
body = job.body
|
@@ -182,13 +189,21 @@ class Host
|
|
182
189
|
self._SendAlreadyWrappedAndSerialised(serialized_object, @config.errorQueueName)
|
183
190
|
job.delete
|
184
191
|
end
|
192
|
+
rescue SystemExit, Interrupt
|
193
|
+
puts "Exiting on request ..."
|
194
|
+
messageLoop = false
|
185
195
|
rescue Exception => e
|
186
196
|
if e.message == "TIMED_OUT" then
|
197
|
+
#This exception is just saying there are no messages to process
|
198
|
+
statOutputCountdown = 0
|
199
|
+
elsif e.message == "SIGTERM" then
|
200
|
+
puts "Exiting on request ..."
|
201
|
+
messageLoop = false
|
187
202
|
else
|
188
203
|
puts "*** This is really unexpected."
|
189
|
-
|
204
|
+
messageLoop = false
|
205
|
+
puts "Message: " + e.message
|
190
206
|
puts e.backtrace
|
191
|
-
abort()
|
192
207
|
end
|
193
208
|
end
|
194
209
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rservicebus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
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: 2012-
|
12
|
+
date: 2012-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby interpretation of NServiceBus
|
15
15
|
email: guy@guyirvine.com
|
@@ -20,6 +20,7 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- lib/rservicebus/Agent.rb
|
23
|
+
- lib/rservicebus/AppResource/Mysql.rb
|
23
24
|
- lib/rservicebus/AppResource/Redis.rb
|
24
25
|
- lib/rservicebus/AppResource.rb
|
25
26
|
- lib/rservicebus/Config.rb
|