rservicebus 0.0.64 → 0.0.65
Sign up to get free protection for your applications and to get access to all the features.
@@ -17,13 +17,14 @@ module RServiceBus
|
|
17
17
|
|
18
18
|
def _connect
|
19
19
|
@connection = self.connect(@uri)
|
20
|
-
|
20
|
+
@host.log "#{self.class.name}. Connected to, #{@uri.to_s}", true
|
21
21
|
end
|
22
22
|
|
23
23
|
# Resources are attached resources, and can be specified using the URI syntax.
|
24
24
|
#
|
25
25
|
# @param [String] uri a location for the resource to which we will attach, eg redis://127.0.0.1/foo
|
26
|
-
def initialize( uri )
|
26
|
+
def initialize( host, uri )
|
27
|
+
@host = host
|
27
28
|
@uri = uri
|
28
29
|
#Do a connect / disconnect loop on startup to validate the connection
|
29
30
|
self._connect
|
@@ -5,7 +5,7 @@ module RServiceBus
|
|
5
5
|
#Configure AppResources for an rservicebus host
|
6
6
|
class ConfigureAppResource
|
7
7
|
|
8
|
-
def getResources( env )
|
8
|
+
def getResources( env, host )
|
9
9
|
resources = Hash.new
|
10
10
|
|
11
11
|
env.each do |k,v|
|
@@ -14,30 +14,30 @@ module RServiceBus
|
|
14
14
|
uri = URI.parse( v )
|
15
15
|
case uri.scheme
|
16
16
|
when "redis"
|
17
|
-
resources[k.sub( "RSB_", "" )] = AppResource_Redis.new( uri )
|
17
|
+
resources[k.sub( "RSB_", "" )] = AppResource_Redis.new( host, uri )
|
18
18
|
|
19
19
|
when "mysql"
|
20
20
|
require "rservicebus/AppResource/Mysql"
|
21
|
-
resources[k.sub( "RSB_", "" )] = AppResource_Mysql.new( uri )
|
21
|
+
resources[k.sub( "RSB_", "" )] = AppResource_Mysql.new( host, uri )
|
22
22
|
|
23
23
|
when "fluiddbmysql"
|
24
24
|
require "rservicebus/AppResource/FluidDbMysql"
|
25
|
-
resources[k.sub( "RSB_", "" )] = AppResource_FluidDbMysql.new( uri )
|
25
|
+
resources[k.sub( "RSB_", "" )] = AppResource_FluidDbMysql.new( host, uri )
|
26
26
|
when "fluiddbmysql2"
|
27
27
|
require "rservicebus/AppResource/FluidDbMysql2"
|
28
|
-
resources[k.sub( "RSB_", "" )] = AppResource_FluidDbMysql2.new( uri )
|
28
|
+
resources[k.sub( "RSB_", "" )] = AppResource_FluidDbMysql2.new( host, uri )
|
29
29
|
when "fluiddbpgsql"
|
30
30
|
require "rservicebus/AppResource/FluidDbPgsql"
|
31
|
-
resources[k.sub( "RSB_", "" )] = AppResource_FluidDbPgsql.new( uri )
|
31
|
+
resources[k.sub( "RSB_", "" )] = AppResource_FluidDbPgsql.new( host, uri )
|
32
32
|
when "fluiddbtinytds"
|
33
33
|
require "rservicebus/AppResource/FluidDbTinyTds"
|
34
|
-
resources[k.sub( "RSB_", "" )] = AppResource_FluidDbTinyTds.new( uri )
|
34
|
+
resources[k.sub( "RSB_", "" )] = AppResource_FluidDbTinyTds.new( host, uri )
|
35
35
|
when "dir"
|
36
36
|
require "rservicebus/AppResource/Dir"
|
37
|
-
resources[k.sub( "RSB_", "" )] = AppResource_Dir.new( uri )
|
37
|
+
resources[k.sub( "RSB_", "" )] = AppResource_Dir.new( host, uri )
|
38
38
|
when "file"
|
39
39
|
require "rservicebus/AppResource/File"
|
40
|
-
resources[k.sub( "RSB_", "" )] = AppResource_File.new( uri )
|
40
|
+
resources[k.sub( "RSB_", "" )] = AppResource_File.new( host, uri )
|
41
41
|
else
|
42
42
|
abort("Scheme, #{uri.scheme}, not recognised when configuring app resource, #{k}=#{v}");
|
43
43
|
end
|
@@ -59,13 +59,13 @@ module RServiceBus
|
|
59
59
|
#
|
60
60
|
# @param [RServiceBus::Handler] handler
|
61
61
|
## @param [Hash] appResources As hash[k,v] where k is the name of a resource, and v is the resource
|
62
|
-
def
|
62
|
+
def setAppResources_to_be_removed( handler )
|
63
63
|
@host.log "Checking app resources for: #{handler.class.name}", true
|
64
64
|
@host.log "If your attribute is not getting set, check that it is in the 'attr_accessor' list", true
|
65
65
|
@appResources.each do |k,v|
|
66
66
|
if handler.class.method_defined?( k ) then
|
67
67
|
v._connect
|
68
|
-
v.Begin
|
68
|
+
# v.Begin
|
69
69
|
handler.instance_variable_set( "@#{k}", v.getResource() )
|
70
70
|
@host.log "App resource attribute, #{k}, set for: " + handler.class.name
|
71
71
|
end
|
@@ -89,7 +89,7 @@ module RServiceBus
|
|
89
89
|
next if @resourceListByHandlerName[handler.class.name].nil?
|
90
90
|
@resourceListByHandlerName[handler.class.name].each do |k|
|
91
91
|
handler.instance_variable_set( "@#{k}", @appResources[k].getResource() )
|
92
|
-
@host.log "App resource attribute, #{k}, set for: " + handler.class.name
|
92
|
+
@host.log "App resource attribute, #{k}, set for: " + handler.class.name, true
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -100,10 +100,10 @@ module RServiceBus
|
|
100
100
|
|
101
101
|
list = self.getListOfResourcesNeededToProcessMsg( msgName )
|
102
102
|
list.each do |resourceName|
|
103
|
-
@host.log( "Preparing reousrce: #{resourceName}", true )
|
104
103
|
r = @appResources[resourceName]
|
105
104
|
r._connect
|
106
105
|
r.Begin
|
106
|
+
@host.log( "Preparing resource: #{resourceName}. Begin", true )
|
107
107
|
end
|
108
108
|
|
109
109
|
self.setResourcesForHandlersNeededToProcessMsg( msgName )
|
data/lib/rservicebus/Host.rb
CHANGED
@@ -45,7 +45,7 @@ module RServiceBus
|
|
45
45
|
#Thin veneer for Configuring external resources
|
46
46
|
#
|
47
47
|
def configureAppResource
|
48
|
-
@appResources = ConfigureAppResource.new.getResources( ENV )
|
48
|
+
@appResources = ConfigureAppResource.new.getResources( ENV, self )
|
49
49
|
return self;
|
50
50
|
end
|
51
51
|
|
@@ -188,7 +188,7 @@ module RServiceBus
|
|
188
188
|
#Popping a msg off the queue should not be in the message handler, as it affects retry
|
189
189
|
begin
|
190
190
|
if statOutputCountdown == 0 then
|
191
|
-
log @stats.getForReporting
|
191
|
+
log @stats.getForReporting, true
|
192
192
|
statOutputCountdown = @config.statOutputCountdown
|
193
193
|
GC.start
|
194
194
|
end
|
@@ -267,10 +267,14 @@ module RServiceBus
|
|
267
267
|
rescue NoMsgToProcess => e
|
268
268
|
#This exception is just saying there are no messages to process
|
269
269
|
statOutputCountdown = 0
|
270
|
-
|
270
|
+
@queueForMsgsToBeSentOnComplete = Array.new
|
271
|
+
|
271
272
|
@monitors.each do |o|
|
272
273
|
o.Look
|
273
274
|
end
|
275
|
+
|
276
|
+
self.sendQueuedMsgs
|
277
|
+
@queueForMsgsToBeSentOnComplete = nil
|
274
278
|
|
275
279
|
|
276
280
|
rescue Exception => e
|
@@ -18,18 +18,48 @@ module RServiceBus
|
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
+
def checkSendHash
|
22
|
+
if !@QueryStringParts.nil? && @QueryStringParts.has_key?("hash") then
|
23
|
+
flag = @QueryStringParts["hash"][0]
|
24
|
+
return flag == "Y"
|
25
|
+
end
|
26
|
+
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def SendArray( payload, uri )
|
32
|
+
payload.each do |csvline|
|
33
|
+
self.send( csvline, uri )
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def SendHash( payload, uri )
|
38
|
+
headLine = payload.shift
|
39
|
+
payload.each do |csvline|
|
40
|
+
hash = Hash.new
|
41
|
+
csvline.each_with_index do |v,idx|
|
42
|
+
hash[headLine[idx]] = v
|
43
|
+
end
|
44
|
+
self.send( hash, uri )
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
21
48
|
def ProcessPath( filePath )
|
22
49
|
uri = URI.parse( "file://#{filePath}" )
|
23
50
|
|
24
51
|
content = IO.read( filePath )
|
25
52
|
payload = CSV.parse( content )
|
26
53
|
|
27
|
-
self.checkPayloadForNumberOfColumns( payload )
|
28
54
|
|
29
|
-
|
30
|
-
|
55
|
+
self.checkPayloadForNumberOfColumns( payload )
|
56
|
+
if self.checkSendHash then
|
57
|
+
self.SendHash( payload, uri )
|
58
|
+
else
|
59
|
+
self.SendArray( payload, uri )
|
31
60
|
end
|
32
61
|
|
62
|
+
|
33
63
|
return content
|
34
64
|
end
|
35
65
|
|
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.65
|
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-05-
|
12
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby interpretation of NServiceBus
|
15
15
|
email: guy@guyirvine.com
|