rservicebus 0.0.44 → 0.0.46
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/rservicebus/Host.rb +5 -5
- data/lib/rservicebus/Monitor/CsvDir.rb +2 -2
- data/lib/rservicebus/Monitor/CsvPerLine.rb +8 -3
- data/lib/rservicebus/Monitor/Dir.rb +100 -21
- data/lib/rservicebus/Monitor/Message.rb +4 -2
- data/lib/rservicebus/Monitor/XmlDir.rb +2 -3
- data/lib/rservicebus/Monitor.rb +2 -2
- metadata +2 -2
data/lib/rservicebus/Host.rb
CHANGED
@@ -240,8 +240,8 @@ module RServiceBus
|
|
240
240
|
end
|
241
241
|
|
242
242
|
errorString = e.message + ". " + e.backtrace.join( ". " )
|
243
|
-
log errorString
|
244
|
-
|
243
|
+
# log errorString
|
244
|
+
|
245
245
|
@msg.addErrorMsg( @config.localQueueName, errorString )
|
246
246
|
serialized_object = YAML::dump(@msg)
|
247
247
|
self._SendAlreadyWrappedAndSerialised(serialized_object, @config.errorQueueName)
|
@@ -284,8 +284,8 @@ module RServiceBus
|
|
284
284
|
|
285
285
|
if handlerList == nil then
|
286
286
|
log "No handler found for: " + msgName
|
287
|
-
puts "No handler found for: " + msgName
|
288
|
-
puts YAML::dump(@msg)
|
287
|
+
# puts "No handler found for: " + msgName
|
288
|
+
# puts YAML::dump(@msg)
|
289
289
|
raise "No Handler Found"
|
290
290
|
|
291
291
|
else
|
@@ -295,7 +295,7 @@ module RServiceBus
|
|
295
295
|
handler.Handle( @msg.msg )
|
296
296
|
rescue Exception => e
|
297
297
|
log "An error occured in Handler: " + handler.class.name
|
298
|
-
log e.message + ". " + e.backtrace[0]
|
298
|
+
#log e.message + ". " + e.backtrace[0]
|
299
299
|
raise e
|
300
300
|
end
|
301
301
|
end
|
@@ -4,10 +4,15 @@ require 'csv'
|
|
4
4
|
class Monitor_CsvPerLineDir<Monitor_Dir
|
5
5
|
|
6
6
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
7
|
+
def ProcessPath( filePath )
|
8
|
+
uri = URI.parse( "file://#{filePath}" )
|
9
|
+
|
10
|
+
content = IO.read( filePath )
|
11
|
+
CSV.parse( content ).each do |csvline|
|
12
|
+
self.send( csvline, uri )
|
10
13
|
end
|
14
|
+
|
15
|
+
return content
|
11
16
|
end
|
12
17
|
|
13
18
|
end
|
@@ -1,52 +1,131 @@
|
|
1
|
+
require 'rubygems/package'
|
1
2
|
require 'cgi'
|
3
|
+
require 'zip/zip'
|
4
|
+
require 'zlib'
|
2
5
|
|
3
6
|
class Monitor_Dir<Monitor
|
4
7
|
|
5
8
|
@Path
|
6
9
|
@ArchiveDir
|
10
|
+
@InputFilter
|
7
11
|
|
8
12
|
def connect(uri)
|
9
13
|
#Pass the path through the Dir object to check syntax on startup
|
10
14
|
inputDir = Dir.new( uri.path )
|
11
15
|
@Path = inputDir.path
|
16
|
+
@InputFilter = Array.new
|
12
17
|
|
13
18
|
return if uri.query.nil?
|
14
19
|
parts = CGI.parse(uri.query)
|
15
|
-
|
20
|
+
if parts.has_key?("archive") then
|
21
|
+
archiveUri = URI.parse( parts["archive"][0] )
|
22
|
+
if !File.directory?( archiveUri.path ) then
|
23
|
+
puts "***** Archive file name templating not yet supported."
|
24
|
+
puts "***** Directory's only."
|
25
|
+
abort()
|
26
|
+
end
|
27
|
+
@ArchiveDir = archiveUri.path
|
28
|
+
end
|
16
29
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
if parts.has_key?("inputfilter") then
|
31
|
+
if parts["inputfilter"].count > 1 then
|
32
|
+
puts "Too many inputfilters specified."
|
33
|
+
puts "*** ZIP, or GZ are the only valid inputfilters."
|
34
|
+
abort();
|
35
|
+
end
|
36
|
+
|
37
|
+
if parts["inputfilter"][0] == "ZIP" then
|
38
|
+
elsif parts["inputfilter"][0] == "GZ" then
|
39
|
+
elsif parts["inputfilter"][0] == "TAR" then
|
40
|
+
else
|
41
|
+
puts "Invalid inputfilter specified."
|
42
|
+
puts "*** ZIP, or GZ are the only valid inputfilters."
|
43
|
+
abort();
|
44
|
+
end
|
45
|
+
@InputFilter << parts["inputfilter"][0]
|
22
46
|
end
|
23
47
|
|
24
|
-
@ArchiveDir = archiveUri.path
|
25
48
|
|
26
49
|
end
|
27
50
|
|
28
|
-
def
|
29
|
-
return
|
51
|
+
def ProcessContent( content )
|
52
|
+
return content
|
30
53
|
end
|
31
54
|
|
32
|
-
def
|
33
|
-
|
55
|
+
def ReadContentFromZipFile( filePath )
|
56
|
+
zip = Zip::ZipInputStream::open(filePath)
|
57
|
+
entry = zip.get_next_entry
|
58
|
+
content = zip.read
|
59
|
+
zip.close
|
34
60
|
|
35
|
-
|
61
|
+
return entry, content
|
62
|
+
end
|
63
|
+
|
64
|
+
def ReadContentFromGzFile( filePath )
|
65
|
+
gz = Zlib::GzipReader.open(filePath)
|
66
|
+
return gz.read
|
67
|
+
end
|
68
|
+
|
69
|
+
def ReadContentFromTarFile( filePath )
|
70
|
+
content = ""
|
71
|
+
Gem::Package::TarReader.new( filePath ).each do |entry|
|
72
|
+
content = entry.read
|
73
|
+
return content
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def ReadContentFromFile( filePath )
|
78
|
+
content = ""
|
79
|
+
if @InputFilter.length > 0 then
|
80
|
+
if @InputFilter[0] == 'ZIP' then
|
81
|
+
entry, content = self.ReadContentFromZipFile( filePath )
|
82
|
+
elsif @InputFilter[0] == 'GZ' then
|
83
|
+
content = self.ReadContentFromGzFile( filePath )
|
84
|
+
elsif @InputFilter[0] == 'TAR' then
|
85
|
+
content = self.ReadContentFromTarFile( filePath )
|
86
|
+
end
|
87
|
+
|
88
|
+
else
|
89
|
+
content = IO.read( filePath )
|
90
|
+
end
|
91
|
+
|
92
|
+
return content
|
93
|
+
end
|
94
|
+
|
95
|
+
def ProcessPath( filePath )
|
96
|
+
content = self.ReadContentFromFile( filePath )
|
97
|
+
payload = self.ProcessContent( content )
|
98
|
+
|
99
|
+
self.send( payload, URI.parse( "file://#{filePath}" ) )
|
100
|
+
return content
|
36
101
|
end
|
37
102
|
|
38
103
|
def Look
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
104
|
+
fileProcessed = 0
|
105
|
+
maxFilesProcessed = 10
|
106
|
+
|
107
|
+
fileList = Dir.glob( "#{@Path}/*" )
|
108
|
+
fileList.each do |filePath|
|
109
|
+
@Bus.log "Ready to process, #{filePath}", true
|
110
|
+
content = self.ProcessPath( filePath )
|
111
|
+
|
112
|
+
if !@ArchiveDir.nil? then
|
113
|
+
basename = File.basename( filePath )
|
114
|
+
newFilePath = @ArchiveDir + "/" + basename + "." + DateTime.now.strftime( "%Y%m%d%H%M%S%L") + ".zip"
|
47
115
|
@Bus.log "Writing to archive, #{newFilePath}", true
|
48
|
-
|
116
|
+
|
117
|
+
Zip::ZipOutputStream.open(newFilePath) {
|
118
|
+
|zos|
|
119
|
+
zos.put_next_entry(basename)
|
120
|
+
zos.puts content
|
121
|
+
}
|
49
122
|
end
|
123
|
+
File.unlink( filePath )
|
124
|
+
|
125
|
+
fileProcessed = fileProcessed + 1
|
126
|
+
@Bus.log "Processed #{fileProcessed} of #{fileList.length}.", true
|
127
|
+
@Bus.log "Allow system tick #{self.class.name}", true
|
128
|
+
return if fileProcessed >= maxFilesProcessed
|
50
129
|
end
|
51
130
|
|
52
131
|
end
|
data/lib/rservicebus/Monitor.rb
CHANGED
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.46
|
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-03-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby interpretation of NServiceBus
|
15
15
|
email: guy@guyirvine.com
|