rservicebus 0.1.42 → 0.1.43
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rservicebus.rb +1 -0
- data/lib/rservicebus/Config.rb +3 -11
- data/lib/rservicebus/Host.rb +7 -6
- data/lib/rservicebus/Message.rb +71 -71
- data/lib/rservicebus/Message/VerboseOutput.rb +10 -0
- data/lib/rservicebus/helper_functions.rb +4 -4
- metadata +12 -11
data/lib/rservicebus.rb
CHANGED
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, :subscriptionUri, :
|
5
|
+
attr_reader :appName, :messageEndpointMappings, :handlerPathList, :localQueueName, :errorQueueName, :maxRetries, :forwardReceivedMessagesTo, :subscriptionUri, :queueTimeout, :statOutputCountdown, :contractList, :libList, :forwardSentMessagesTo, :mqHost
|
6
6
|
|
7
7
|
@appName
|
8
8
|
@messageEndpointMappings
|
@@ -16,8 +16,6 @@ module RServiceBus
|
|
16
16
|
@forwardReceivedMessagesTo
|
17
17
|
@subscriptionUri
|
18
18
|
|
19
|
-
@verbose
|
20
|
-
|
21
19
|
@mq
|
22
20
|
|
23
21
|
@queueTimeout
|
@@ -141,13 +139,7 @@ module RServiceBus
|
|
141
139
|
end
|
142
140
|
return self
|
143
141
|
end
|
144
|
-
|
145
|
-
def configureLogging()
|
146
|
-
@verbose = !self.getValue( "VERBOSE", nil ).nil?
|
147
|
-
|
148
|
-
return self
|
149
|
-
end
|
150
|
-
|
142
|
+
|
151
143
|
def configureMq
|
152
144
|
@mqHost = self.getValue( "MQ", "beanstalk://localhost" )
|
153
145
|
return self
|
@@ -193,7 +185,7 @@ module RServiceBus
|
|
193
185
|
end
|
194
186
|
|
195
187
|
class ConfigFromSetter<Config
|
196
|
-
attr_writer :appName, :messageEndpointMappings, :handlerPathList, :localQueueName, :errorQueueName, :maxRetries, :forwardReceivedMessagesTo, :
|
188
|
+
attr_writer :appName, :messageEndpointMappings, :handlerPathList, :localQueueName, :errorQueueName, :maxRetries, :forwardReceivedMessagesTo, :beanstalkHost
|
197
189
|
|
198
190
|
def initialize()
|
199
191
|
end
|
data/lib/rservicebus/Host.rb
CHANGED
@@ -37,11 +37,7 @@ module RServiceBus
|
|
37
37
|
# @param [String] string Log entry
|
38
38
|
# @param [Boolean] ver Indicator for a verbose log entry
|
39
39
|
def log(string, ver=false)
|
40
|
-
|
41
|
-
if @config.verbose || !ver then
|
42
|
-
timestamp = Time.new.strftime( "%Y-%m-%d %H:%M:%S" )
|
43
|
-
puts "[#{type}] #{timestamp} :: #{string}"
|
44
|
-
end
|
40
|
+
RServiceBus.log( string, ver )
|
45
41
|
end
|
46
42
|
|
47
43
|
#Thin veneer for Configuring external resources
|
@@ -156,7 +152,6 @@ module RServiceBus
|
|
156
152
|
|
157
153
|
def initialize()
|
158
154
|
@config = ConfigFromEnv.new
|
159
|
-
.configureLogging()
|
160
155
|
.loadHostSection()
|
161
156
|
.configureMq()
|
162
157
|
.loadContracts()
|
@@ -228,6 +223,12 @@ module RServiceBus
|
|
228
223
|
@stats.output = true
|
229
224
|
elsif @msg.msg.class.name == "RServiceBus::Message_StatisticOutputOff" then
|
230
225
|
@stats.output = false
|
226
|
+
elsif @msg.msg.class.name == "RServiceBus::Message_VerboseOutputOn" then
|
227
|
+
ENV["VERBOSE"] = "true"
|
228
|
+
log "Turn on Verbose logging"
|
229
|
+
elsif @msg.msg.class.name == "RServiceBus::Message_VerboseOutputOff" then
|
230
|
+
ENV.delete( "VERBOSE" )
|
231
|
+
log "Turn off Verbose logging"
|
231
232
|
|
232
233
|
|
233
234
|
else
|
data/lib/rservicebus/Message.rb
CHANGED
@@ -1,81 +1,81 @@
|
|
1
1
|
module RServiceBus
|
2
|
-
|
3
|
-
require 'zlib'
|
4
|
-
|
5
|
-
#This is the top level message that is passed around the bus
|
6
|
-
class Message
|
7
|
-
|
8
|
-
attr_reader :returnAddress, :msgId, :remoteQueueName, :remoteHostName, :lastErrorSourceQueue, :lastErrorString
|
9
|
-
|
10
|
-
# Constructor
|
11
|
-
#
|
12
|
-
# @param [Object] msg The msg to be sent
|
13
|
-
# @param [Object] returnAddress A queue to which the destination message handler can send replies
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
2
|
+
|
3
|
+
require 'zlib'
|
4
|
+
|
5
|
+
#This is the top level message that is passed around the bus
|
6
|
+
class Message
|
7
|
+
|
8
|
+
attr_reader :returnAddress, :msgId, :remoteQueueName, :remoteHostName, :lastErrorSourceQueue, :lastErrorString
|
9
|
+
|
10
|
+
# Constructor
|
11
|
+
#
|
12
|
+
# @param [Object] msg The msg to be sent
|
13
|
+
# @param [Object] returnAddress A queue to which the destination message handler can send replies
|
14
|
+
def initialize( msg, returnAddress )
|
15
|
+
if ENV["RSBMSG_COMPRESS"].nil? then
|
16
|
+
@compressed = false
|
17
|
+
@_msg=YAML::dump(msg)
|
18
|
+
else
|
19
|
+
@compressed = true
|
20
|
+
@_msg=Zlib::Deflate.deflate(YAML::dump(msg))
|
21
|
+
end
|
22
|
+
|
23
|
+
@returnAddress=returnAddress
|
24
|
+
|
25
|
+
@createdAt = DateTime.now
|
26
|
+
|
27
|
+
@msgId=UUIDTools::UUID.random_create
|
28
|
+
@errorList = Array.new
|
29
|
+
end
|
30
|
+
|
31
|
+
# If an error occurs while processing the message, this method allows details of the error to held
|
32
|
+
# next to the msg.
|
33
|
+
#
|
34
|
+
# Error(s) are held in an array, which allows current error information to be held, while still
|
35
|
+
# retaining historical error messages.
|
36
|
+
#
|
37
|
+
# @param [Object] sourceQueue The name of the queue to which the msg should be returned
|
38
|
+
# @param [Object] errorString A readible version of what occured
|
39
|
+
def addErrorMsg( sourceQueue, errorString )
|
40
|
+
@lastErrorSourceQueue = sourceQueue
|
41
|
+
@lastErrorString = errorString
|
42
|
+
|
43
|
+
@errorList << RServiceBus::ErrorMessage.new( sourceQueue, errorString )
|
21
44
|
end
|
22
45
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
# If an error occurs while processing the message, this method allows details of the error to held
|
32
|
-
# next to the msg.
|
33
|
-
#
|
34
|
-
# Error(s) are held in an array, which allows current error information to be held, while still
|
35
|
-
# retaining historical error messages.
|
36
|
-
#
|
37
|
-
# @param [Object] sourceQueue The name of the queue to which the msg should be returned
|
38
|
-
# @param [Object] errorString A readible version of what occured
|
39
|
-
def addErrorMsg( sourceQueue, errorString )
|
40
|
-
@lastErrorSourceQueue = sourceQueue
|
41
|
-
@lastErrorString = errorString
|
46
|
+
# Convenience function
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
def getLastErrorMsg
|
50
|
+
return @errorList.last
|
51
|
+
end
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
return @errorList.last
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
def setRemoteHostName( hostName )
|
55
|
-
@remoteHostName = hostName
|
56
|
-
end
|
57
|
-
|
58
|
-
def setRemoteQueueName( queueName )
|
59
|
-
@remoteQueueName = queueName
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
# @return [Object] The msg to be sent
|
64
|
-
def msg
|
65
|
-
if @compressed == true then
|
66
|
-
return YAML::load( Zlib::Inflate.inflate( @_msg ))
|
67
|
-
else
|
68
|
-
return YAML::load( @_msg )
|
53
|
+
|
54
|
+
def setRemoteHostName( hostName )
|
55
|
+
@remoteHostName = hostName
|
56
|
+
end
|
57
|
+
|
58
|
+
def setRemoteQueueName( queueName )
|
59
|
+
@remoteQueueName = queueName
|
69
60
|
end
|
70
|
-
|
61
|
+
|
62
|
+
|
63
|
+
# @return [Object] The msg to be sent
|
64
|
+
def msg
|
65
|
+
if @compressed == true then
|
66
|
+
return YAML::load( Zlib::Inflate.inflate( @_msg ))
|
67
|
+
else
|
68
|
+
return YAML::load( @_msg )
|
69
|
+
end
|
70
|
+
rescue ArgumentError => e
|
71
71
|
raise e if e.message.index( "undefined class/module " ).nil?
|
72
|
-
|
72
|
+
|
73
73
|
puts e.message
|
74
74
|
msg_name = e.message.sub( "undefined class/module ", "" )
|
75
|
-
|
75
|
+
|
76
76
|
raise ClassNotFoundForMsg.new( msg_name )
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
81
|
end
|
@@ -18,10 +18,10 @@ module RServiceBus
|
|
18
18
|
return unless ENV['TESTING'].nil?
|
19
19
|
|
20
20
|
type = ver ? "VERB" : "INFO"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
if !ENV["VERBOSE"].nil? || !ver then
|
22
|
+
timestamp = Time.new.strftime( "%Y-%m-%d %H:%M:%S" )
|
23
|
+
puts "[#{type}] #{timestamp} :: #{string}"
|
24
|
+
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def RServiceBus.createAnonymousClass( name_for_class )
|
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.1.
|
4
|
+
version: 0.1.43
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-10-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: uuidtools
|
16
|
-
requirement: &
|
16
|
+
requirement: &70183868520680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70183868520680
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70183868520020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70183868520020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: beanstalk-client
|
38
|
-
requirement: &
|
38
|
+
requirement: &70183868519240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70183868519240
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: fluiddb
|
49
|
-
requirement: &
|
49
|
+
requirement: &70183868518700 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70183868518700
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: parse-cron
|
60
|
-
requirement: &
|
60
|
+
requirement: &70183868518120 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70183868518120
|
69
69
|
description: A Ruby interpretation of NServiceBus
|
70
70
|
email: guy@guyirvine.com
|
71
71
|
executables:
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/rservicebus/Host.rb
|
111
111
|
- lib/rservicebus/Message/StatisticOutput.rb
|
112
112
|
- lib/rservicebus/Message/Subscription.rb
|
113
|
+
- lib/rservicebus/Message/VerboseOutput.rb
|
113
114
|
- lib/rservicebus/Message.rb
|
114
115
|
- lib/rservicebus/Monitor/CsvDir.rb
|
115
116
|
- lib/rservicebus/Monitor/CsvPerLine.rb
|