rservicebus 0.1.74 → 0.1.75

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.
Files changed (66) hide show
  1. data/bin/ReturnMessagesToSourceQueue +18 -18
  2. data/bin/SendEmptyMessage +3 -3
  3. data/bin/rsb_ctl +10 -10
  4. data/bin/rservicebus-create +4 -4
  5. data/bin/rservicebus-init +7 -6
  6. data/lib/rservicebus.rb +49 -49
  7. data/lib/rservicebus/Agent.rb +4 -4
  8. data/lib/rservicebus/AppResource.rb +4 -4
  9. data/lib/rservicebus/AppResource/Dir.rb +3 -3
  10. data/lib/rservicebus/AppResource/FluidDb.rb +1 -1
  11. data/lib/rservicebus/AppResource/FluidDbFirebird.rb +1 -1
  12. data/lib/rservicebus/AppResource/FluidDbMysql.rb +4 -4
  13. data/lib/rservicebus/AppResource/FluidDbMysql2.rb +4 -4
  14. data/lib/rservicebus/AppResource/FluidDbPgsql.rb +4 -4
  15. data/lib/rservicebus/AppResource/FluidDbTinyTds.rb +1 -1
  16. data/lib/rservicebus/AppResource/Mysql.rb +2 -2
  17. data/lib/rservicebus/AppResource/Redis.rb +1 -1
  18. data/lib/rservicebus/AppResource/ScpDownload.rb +51 -0
  19. data/lib/rservicebus/AppResource/ScpUpload.rb +3 -2
  20. data/lib/rservicebus/AppResource/Smb.rb +3 -3
  21. data/lib/rservicebus/AppResource/SmbDir.rb +2 -2
  22. data/lib/rservicebus/AppResource/SmbFile.rb +1 -1
  23. data/lib/rservicebus/Audit.rb +9 -9
  24. data/lib/rservicebus/CircuitBreaker.rb +4 -4
  25. data/lib/rservicebus/Config.rb +46 -46
  26. data/lib/rservicebus/ConfigureAppResource.rb +64 -63
  27. data/lib/rservicebus/ConfigureMonitor.rb +12 -12
  28. data/lib/rservicebus/ConfigureSubscriptionStorage.rb +5 -5
  29. data/lib/rservicebus/CronManager.rb +8 -8
  30. data/lib/rservicebus/EndpointMapping.rb +11 -11
  31. data/lib/rservicebus/HandlerLoader.rb +33 -33
  32. data/lib/rservicebus/HandlerManager.rb +2 -2
  33. data/lib/rservicebus/Host.rb +58 -58
  34. data/lib/rservicebus/MQ.rb +21 -21
  35. data/lib/rservicebus/MQ/Beanstalk.rb +9 -9
  36. data/lib/rservicebus/MQ/RabbitMq.rb +5 -5
  37. data/lib/rservicebus/MQ/Redis.rb +3 -3
  38. data/lib/rservicebus/Message.rb +11 -11
  39. data/lib/rservicebus/Monitor.rb +5 -5
  40. data/lib/rservicebus/Monitor/CsvDir.rb +5 -5
  41. data/lib/rservicebus/Monitor/CsvPerLine.rb +5 -5
  42. data/lib/rservicebus/Monitor/Dir.rb +34 -34
  43. data/lib/rservicebus/Monitor/DirNotifier.rb +15 -15
  44. data/lib/rservicebus/ResourceManager.rb +2 -2
  45. data/lib/rservicebus/Saga/Manager.rb +18 -18
  46. data/lib/rservicebus/SagaLoader.rb +19 -19
  47. data/lib/rservicebus/SagaStorage.rb +4 -4
  48. data/lib/rservicebus/SagaStorage/Dir.rb +12 -12
  49. data/lib/rservicebus/SendAtManager.rb +4 -4
  50. data/lib/rservicebus/SendAtStorage.rb +5 -5
  51. data/lib/rservicebus/SendAtStorage/File.rb +3 -3
  52. data/lib/rservicebus/StateManager.rb +2 -2
  53. data/lib/rservicebus/StateStorage.rb +2 -2
  54. data/lib/rservicebus/StateStorage/Dir.rb +11 -11
  55. data/lib/rservicebus/StateStorage/InMemory.rb +1 -1
  56. data/lib/rservicebus/StatisticManager.rb +2 -2
  57. data/lib/rservicebus/SubscriptionManager.rb +2 -2
  58. data/lib/rservicebus/SubscriptionStorage.rb +4 -4
  59. data/lib/rservicebus/SubscriptionStorage/File.rb +3 -3
  60. data/lib/rservicebus/SubscriptionStorage/Redis.rb +10 -10
  61. data/lib/rservicebus/Test.rb +2 -2
  62. data/lib/rservicebus/Test/Bus.rb +2 -2
  63. data/lib/rservicebus/Test/Redis.rb +1 -1
  64. data/lib/rservicebus/Transporter.rb +15 -15
  65. data/lib/rservicebus/helper_functions.rb +15 -15
  66. metadata +13 -12
@@ -44,29 +44,29 @@ module RServiceBus
44
44
 
45
45
  env.each do |k,v|
46
46
  if v.is_a?(String) and
47
- k.start_with?( "RSBOB_" ) then
47
+ k.start_with?('RSBOB_') then
48
48
  uri = URI.parse( v )
49
- name = k.sub( "RSBOB_", "" )
49
+ name = k.sub( 'RSBOB_', '')
50
50
  monitor = nil?
51
51
  case uri.scheme
52
- when "csvdir"
53
- require "rservicebus/Monitor/CsvDir"
52
+ when 'csvdir'
53
+ require 'rservicebus/Monitor/CsvDir'
54
54
  monitor = Monitor_CsvDir.new( @host, name, uri )
55
55
 
56
- when "xmldir"
57
- require "rservicebus/Monitor/XmlDir"
56
+ when 'xmldir'
57
+ require 'rservicebus/Monitor/XmlDir'
58
58
  monitor = Monitor_XmlDir.new( @host, name, uri )
59
59
 
60
- when "dir"
61
- require "rservicebus/Monitor/Dir"
60
+ when 'dir'
61
+ require 'rservicebus/Monitor/Dir'
62
62
  monitor = Monitor_Dir.new( @host, name, uri )
63
63
 
64
- when "dirnotifier"
65
- require "rservicebus/Monitor/DirNotifier"
64
+ when 'dirnotifier'
65
+ require 'rservicebus/Monitor/DirNotifier'
66
66
  monitor = Monitor_DirNotifier.new( @host, name, uri )
67
67
 
68
- when "csvperlinedir"
69
- require "rservicebus/Monitor/CsvPerLine"
68
+ when 'csvperlinedir'
69
+ require 'rservicebus/Monitor/CsvPerLine'
70
70
  monitor = Monitor_CsvPerLineDir.new( @host, name, uri )
71
71
  else
72
72
  abort("Scheme, #{uri.scheme}, not recognised when configuring Monitor, #{k}=#{v}");
@@ -1,6 +1,6 @@
1
1
  module RServiceBus
2
2
 
3
- require "uri"
3
+ require 'uri'
4
4
 
5
5
  #Configure SubscriptionStorage for an rservicebus host
6
6
  class ConfigureSubscriptionStorage
@@ -9,12 +9,12 @@ module RServiceBus
9
9
  uri = URI.parse( uri_string )
10
10
 
11
11
  case uri.scheme
12
- when "redis"
13
- require "rservicebus/SubscriptionStorage/Redis"
12
+ when 'redis'
13
+ require 'rservicebus/SubscriptionStorage/Redis'
14
14
  s = SubscriptionStorage_Redis.new( appName, uri )
15
15
 
16
- when "file"
17
- require "rservicebus/SubscriptionStorage/File"
16
+ when 'file'
17
+ require 'rservicebus/SubscriptionStorage/File'
18
18
  s = SubscriptionStorage_File.new( appName, uri )
19
19
 
20
20
  else
@@ -47,7 +47,7 @@ class CronManager
47
47
  hash['cron'] = CronParser.new(cron_string)
48
48
  hash['next'] = hash['cron'].next(Time.now)
49
49
  @list << hash
50
- @Bus.log( "Cron set for, #{n}, #{cron_string}" )
50
+ @Bus.log( "Cron set for, #{n}, #{cron_string}, next run, #{hash['next']}" )
51
51
  end
52
52
  end
53
53
 
@@ -55,16 +55,16 @@ class CronManager
55
55
  @Bus = host
56
56
  @msgNames = msgNames
57
57
 
58
- RServiceBus.rlog "Load Cron"
58
+ RServiceBus.rlog 'Load Cron'
59
59
  @list = Array.new
60
60
  ENV.each do |k,v|
61
- if k.start_with?( "RSBCRON_" ) then
62
- self.addCron( k.sub( "RSBCRON_", "" ), v )
63
- elsif k.start_with?( "RSBCRON" ) then
64
- v.split( ";" ).each do |v|
65
- parts = v.split( " ", 6 )
61
+ if k.start_with?('RSBCRON_') then
62
+ self.addCron( k.sub( 'RSBCRON_', ''), v )
63
+ elsif k.start_with?('RSBCRON') then
64
+ v.split(';').each do |v|
65
+ parts = v.split( ' ', 6 )
66
66
 
67
- self.addCron( parts.pop, parts.join( " " ) )
67
+ self.addCron( parts.pop, parts.join(' ') )
68
68
  end
69
69
  end
70
70
 
@@ -17,7 +17,7 @@ module RServiceBus
17
17
  def configureMapping( mapping )
18
18
  match = mapping.match( /(.+):(.+)/ )
19
19
  if match.nil? then
20
- log "Mapping string provided is invalid"
20
+ log 'Mapping string provided is invalid'
21
21
  log "The entire mapping string is: #{mapping}"
22
22
  log "*** Could not find ':' in mapping entry, #{line}"
23
23
  exit()
@@ -28,29 +28,29 @@ module RServiceBus
28
28
 
29
29
  @queueNameList.each do |q|
30
30
  if q != match[2] && q.downcase == match[2].downcase then
31
- log( "*** Two queues specified with only case sensitive difference." )
31
+ log('*** Two queues specified with only case sensitive difference.')
32
32
  log( "*** #{q} != #{match[2]}" )
33
- log( "*** If you meant these queues to be the same, please match case and restart the bus." )
33
+ log('*** If you meant these queues to be the same, please match case and restart the bus.')
34
34
  end
35
35
  end
36
36
  @queueNameList << match[2]
37
37
  end
38
38
 
39
39
  def Configure( localQueueName=nil )
40
- self.log( "EndpointMapping.Configure" )
40
+ self.log('EndpointMapping.Configure')
41
41
 
42
42
  @queueNameList = []
43
43
  @queueNameList << localQueueName unless localQueueName.nil?
44
-
45
- if !self.getValue( "MESSAGE_ENDPOINT_MAPPING" ).nil? then
46
- log( "*** MESSAGE_ENDPOINT_MAPPING environment variable was detected")
47
- log( "*** You may have intended MESSAGE_ENDPOINT_MAPPINGS, note the 'S' on the end")
44
+
45
+ unless self.getValue('MESSAGE_ENDPOINT_MAPPING').nil? then
46
+ log('*** MESSAGE_ENDPOINT_MAPPING environment variable was detected')
47
+ log("*** You may have intended MESSAGE_ENDPOINT_MAPPINGS, note the 'S' on the end")
48
48
  end
49
49
 
50
- mappings = self.getValue( "MESSAGE_ENDPOINT_MAPPINGS" )
50
+ mappings = self.getValue('MESSAGE_ENDPOINT_MAPPINGS')
51
51
  return self if mappings.nil?
52
52
 
53
- mappings.split( ";" ).each do |mapping|
53
+ mappings.split(';').each do |mapping|
54
54
  self.configureMapping( mapping )
55
55
  end
56
56
 
@@ -70,7 +70,7 @@ module RServiceBus
70
70
  end
71
71
 
72
72
  def getSubscriptionEndpoints
73
- return @endpoints.keys.select { |el| el.end_with?( "Event" ) }
73
+ return @endpoints.keys.select { |el| el.end_with?('Event') }
74
74
  end
75
75
  end
76
76
 
@@ -37,15 +37,15 @@ class HandlerLoader
37
37
  #
38
38
  # @param [String] filePath the path to be cleaned
39
39
  def getRequirePath( filePath )
40
- if !filePath.start_with?( "/" ) then
41
- filePath = "./" + filePath
42
- end
40
+ unless filePath.start_with?('/') then
41
+ filePath = './' + filePath
42
+ end
43
43
 
44
44
  if File.exists?( filePath ) then
45
- return filePath.sub( ".rb", "")
45
+ return filePath.sub( '.rb', '')
46
46
  end
47
47
 
48
- abort( "Filepath, " + filePath + ", given for MessageHandler require doesn't exist" );
48
+ abort( 'Filepath, ' + filePath + ", given for MessageHandler require doesn't exist" );
49
49
  end
50
50
 
51
51
  # Instantiate the handler named in handlerName from the file name in filePath
@@ -63,9 +63,9 @@ class HandlerLoader
63
63
  begin
64
64
  handler = Object.const_get(handlerName).new();
65
65
  rescue Exception => e
66
- puts "Expected class name: " + handlerName + ", not found after require: " + requirePath
67
- puts "**** Check in " + filePath + " that the class is named : " + handlerName
68
- puts "( In case its not that )"
66
+ puts 'Expected class name: ' + handlerName + ', not found after require: ' + requirePath
67
+ puts '**** Check in ' + filePath + ' that the class is named : ' + handlerName
68
+ puts '( In case its not that )'
69
69
  raise e
70
70
  end
71
71
 
@@ -84,17 +84,17 @@ class HandlerLoader
84
84
  end
85
85
 
86
86
  begin
87
- RServiceBus.rlog "filePath: " + filePath
88
- RServiceBus.rlog "handlerName: " + handlerName
87
+ RServiceBus.rlog 'filePath: ' + filePath
88
+ RServiceBus.rlog 'handlerName: ' + handlerName
89
89
 
90
90
  handler = self.loadHandlerFromFile( handlerName, filePath )
91
- RServiceBus.log "Loaded Handler: " + handlerName
91
+ RServiceBus.log 'Loaded Handler: ' + handlerName
92
92
 
93
93
  @handlerManager.addHandler( msgName, handler )
94
94
 
95
95
  @listOfLoadedPaths[filePath] = 1
96
96
  rescue Exception => e
97
- puts "Exception loading handler from file: " + filePath
97
+ puts 'Exception loading handler from file: ' + filePath
98
98
  puts e.message
99
99
  puts e.backtrace[0]
100
100
 
@@ -108,7 +108,7 @@ class HandlerLoader
108
108
  # @param [String] path directory to check
109
109
  # @return [Array] a list of paths to files found in the given path
110
110
  def getListOfFilesForDir( path )
111
- list = Dir[path + "/*"];
111
+ list = Dir[path + '/*'];
112
112
  RServiceBus.rlog "HandlerLoader.getListOfFilesForDir. path: #{path}, list: #{list}"
113
113
 
114
114
  return list
@@ -122,17 +122,17 @@ class HandlerLoader
122
122
  # @param [String] baseDir directory to check for handlers of the given msgName
123
123
  def loadHandlersFromSecondLevelPath(msgName, baseDir)
124
124
  self.getListOfFilesForDir(baseDir).each do |filePath|
125
- if !filePath.end_with?( "." ) then
126
- extName = File.extname( filePath )
127
- if !File.directory?( filePath ) &&
128
- extName == ".rb" then
125
+ unless filePath.end_with?('.') then
126
+ extName = File.extname(filePath)
127
+ if !File.directory?(filePath) &&
128
+ extName == '.rb' then
129
129
 
130
- fileName = File.basename( filePath ).sub( ".rb", "" )
131
- handlerName = "MessageHandler_#{msgName}_#{fileName}"
130
+ fileName = File.basename(filePath).sub('.rb', '')
131
+ handlerName = "MessageHandler_#{msgName}_#{fileName}"
132
132
 
133
- self.loadHandler( msgName, filePath, handlerName )
134
- end
135
- end
133
+ self.loadHandler(msgName, filePath, handlerName)
134
+ end
135
+ end
136
136
  end
137
137
 
138
138
  return self
@@ -145,7 +145,7 @@ class HandlerLoader
145
145
  def getMsgName( filePath )
146
146
  baseName = File.basename( filePath )
147
147
  extName = File.extname( baseName )
148
- fileName = baseName.sub( extName, "" )
148
+ fileName = baseName.sub( extName, '')
149
149
 
150
150
  msgName = fileName
151
151
 
@@ -158,16 +158,16 @@ class HandlerLoader
158
158
  def loadHandlersFromTopLevelPath(baseDir)
159
159
  RServiceBus.rlog "HandlerLoader.loadHandlersFromTopLevelPath. baseDir: #{baseDir}"
160
160
  self.getListOfFilesForDir(baseDir).each do |filePath|
161
- if !filePath.end_with?( "." ) then
162
-
163
- msgName = self.getMsgName( filePath )
164
- if File.directory?( filePath ) then
165
- self.loadHandlersFromSecondLevelPath( msgName, filePath )
166
- else
167
- handlerName = "MessageHandler_#{msgName}"
168
- self.loadHandler( msgName, filePath, handlerName )
169
- end
170
- end
161
+ unless filePath.end_with?('.') then
162
+
163
+ msgName = self.getMsgName(filePath)
164
+ if File.directory?(filePath) then
165
+ self.loadHandlersFromSecondLevelPath(msgName, filePath)
166
+ else
167
+ handlerName = "MessageHandler_#{msgName}"
168
+ self.loadHandler(msgName, filePath, handlerName)
169
+ end
170
+ end
171
171
  end
172
172
 
173
173
  return self
@@ -26,7 +26,7 @@ module RServiceBus
26
26
  def setBusAttributeIfRequested( handler )
27
27
  if defined?( handler.Bus ) then
28
28
  handler.Bus = @host
29
- RServiceBus.log "Bus attribute set for: " + handler.class.name
29
+ RServiceBus.log 'Bus attribute set for: ' + handler.class.name
30
30
  end
31
31
 
32
32
  return self
@@ -38,7 +38,7 @@ module RServiceBus
38
38
  def setStateAttributeIfRequested( handler )
39
39
  if defined?( handler.State ) then
40
40
  handler.State = @stateManager.Get( handler )
41
- RServiceBus.log "Bus attribute set for: " + handler.class.name
41
+ RServiceBus.log 'Bus attribute set for: ' + handler.class.name
42
42
  end
43
43
 
44
44
  return self
@@ -68,9 +68,9 @@ module RServiceBus
68
68
  #Thin veneer for Configuring state
69
69
  #
70
70
  def configureSagaStorage
71
- string = RServiceBus.getValue( "SAGA_URI" )
71
+ string = RServiceBus.getValue('SAGA_URI')
72
72
  if string.nil? then
73
- string = "dir:///tmp"
73
+ string = 'dir:///tmp'
74
74
  end
75
75
 
76
76
  uri = URI.parse( string )
@@ -104,7 +104,7 @@ module RServiceBus
104
104
  #Subscriptions are specified by adding events to the
105
105
  #msg endpoint mapping
106
106
  def sendSubscriptions
107
- log "Send Subscriptions"
107
+ log 'Send Subscriptions'
108
108
 
109
109
  @endpointMapping.getSubscriptionEndpoints.each { |eventName| self.Subscribe( eventName ) }
110
110
 
@@ -114,7 +114,7 @@ module RServiceBus
114
114
  #Load and configure Message Handlers
115
115
  #
116
116
  def loadHandlers()
117
- log "Load Message Handlers"
117
+ log 'Load Message Handlers'
118
118
  @handlerManager = HandlerManager.new( self, @resourceManager, @stateManager )
119
119
  @handlerLoader = HandlerLoader.new( self, @handlerManager )
120
120
 
@@ -127,7 +127,7 @@ module RServiceBus
127
127
 
128
128
  #Load and configure Sagas
129
129
  def loadSagas()
130
- log "Load Sagas"
130
+ log 'Load Sagas'
131
131
  @sagaManager = Saga_Manager.new( self, @resourceManager, @sagaStorage )
132
132
  @sagaLoader = SagaLoader.new( self, @sagaManager )
133
133
 
@@ -148,7 +148,7 @@ module RServiceBus
148
148
  #Load Contracts
149
149
  #
150
150
  def loadContracts()
151
- log "Load Contracts"
151
+ log 'Load Contracts'
152
152
 
153
153
  @config.contractList.each do |path|
154
154
  require path
@@ -161,7 +161,7 @@ module RServiceBus
161
161
  #For each directory given, find and load all librarys
162
162
  #
163
163
  def loadLibs()
164
- log "Load Libs"
164
+ log 'Load Libs'
165
165
 
166
166
  @config.libList.each do |path|
167
167
  $:.unshift path
@@ -224,15 +224,15 @@ module RServiceBus
224
224
  #Ignition
225
225
  #
226
226
  def run
227
- log "Starting the Host"
227
+ log 'Starting the Host'
228
228
 
229
229
  log "Watching, #{@mq.localQueueName}"
230
230
  $0 = "rservicebus - #{@mq.localQueueName}"
231
- if !@config.forwardReceivedMessagesTo.nil? then
232
- log "Forwarding all received messages to: " + @config.forwardReceivedMessagesTo.to_s
231
+ unless @config.forwardReceivedMessagesTo.nil? then
232
+ log 'Forwarding all received messages to: ' + @config.forwardReceivedMessagesTo.to_s
233
233
  end
234
- if !@config.forwardSentMessagesTo.nil? then
235
- log "Forwarding all sent messages to: " + @config.forwardSentMessagesTo.to_s
234
+ unless @config.forwardSentMessagesTo.nil? then
235
+ log 'Forwarding all sent messages to: ' + @config.forwardSentMessagesTo.to_s
236
236
  end
237
237
 
238
238
  self.StartListeningToEndpoints
@@ -241,7 +241,7 @@ module RServiceBus
241
241
  #Receive a msg, prep it, and handle any errors that may occur
242
242
  # - Most of this should be queue independant
243
243
  def StartListeningToEndpoints
244
- log "Waiting for messages. To exit press CTRL+C"
244
+ log 'Waiting for messages. To exit press CTRL+C'
245
245
  # statOutputCountdown = 0
246
246
  messageLoop = true
247
247
  retries = @config.maxRetries
@@ -260,28 +260,28 @@ module RServiceBus
260
260
  begin
261
261
  @stats.incTotalProcessed
262
262
  @msg = YAML::load(body)
263
- if @msg.msg.class.name == "RServiceBus::Message_Subscription" then
263
+ if @msg.msg.class.name == 'RServiceBus::Message_Subscription' then
264
264
  @subscriptionManager.add( @msg.msg.eventName, @msg.returnAddress )
265
- elsif @msg.msg.class.name == "RServiceBus::Message_StatisticOutputOn" then
265
+ elsif @msg.msg.class.name == 'RServiceBus::Message_StatisticOutputOn' then
266
266
  @stats.output = true
267
- log "Turn on Stats logging"
268
- elsif @msg.msg.class.name == "RServiceBus::Message_StatisticOutputOff" then
267
+ log 'Turn on Stats logging'
268
+ elsif @msg.msg.class.name == 'RServiceBus::Message_StatisticOutputOff' then
269
269
  @stats.output = false
270
- log "Turn off Stats logging"
271
- elsif @msg.msg.class.name == "RServiceBus::Message_VerboseOutputOn" then
272
- ENV["VERBOSE"] = "true"
273
- log "Turn on Verbose logging"
274
- elsif @msg.msg.class.name == "RServiceBus::Message_VerboseOutputOff" then
275
- ENV.delete( "VERBOSE" )
276
- log "Turn off Verbose logging"
270
+ log 'Turn off Stats logging'
271
+ elsif @msg.msg.class.name == 'RServiceBus::Message_VerboseOutputOn' then
272
+ ENV['VERBOSE'] = 'true'
273
+ log 'Turn on Verbose logging'
274
+ elsif @msg.msg.class.name == 'RServiceBus::Message_VerboseOutputOff' then
275
+ ENV.delete('VERBOSE')
276
+ log 'Turn off Verbose logging'
277
277
 
278
278
 
279
279
  else
280
280
 
281
281
  self.HandleMessage()
282
282
 
283
- if !@config.forwardReceivedMessagesTo.nil? then
284
- self._SendAlreadyWrappedAndSerialised(body,@config.forwardReceivedMessagesTo)
283
+ unless @config.forwardReceivedMessagesTo.nil? then
284
+ self._SendAlreadyWrappedAndSerialised(body, @config.forwardReceivedMessagesTo)
285
285
  end
286
286
  end
287
287
  @mq.ack
@@ -307,16 +307,16 @@ module RServiceBus
307
307
  #This has been re-rasied from a rescue in the handler
308
308
  puts "*** #{e.message}"
309
309
  #"Property, #{e.message}, not set for, #{handler.class.name}"
310
- propertyName = e.message[10, e.message.index(",", 10)-10]
310
+ propertyName = e.message[10, e.message.index(',', 10)-10]
311
311
  puts "*** Ensure the environment variable, RSB_#{propertyName}, has been set at startup."
312
312
 
313
313
  rescue Exception => e
314
314
  sleep 0.5
315
315
 
316
- puts "*** Exception occurred"
316
+ puts '*** Exception occurred'
317
317
  puts e.message
318
318
  puts e.backtrace
319
- puts "***"
319
+ puts '***'
320
320
 
321
321
  if retries > 0 then
322
322
  retries = retries - 1
@@ -326,19 +326,19 @@ module RServiceBus
326
326
  @circuitBreaker.Failure
327
327
 
328
328
  @stats.incTotalErrored
329
- if e.class.name == "Beanstalk::NotConnected" then
330
- puts "Lost connection to beanstalkd."
331
- puts "*** Start or Restart beanstalkd and try again."
329
+ if e.class.name == 'Beanstalk::NotConnected' then
330
+ puts 'Lost connection to beanstalkd.'
331
+ puts '*** Start or Restart beanstalkd and try again.'
332
332
  abort();
333
333
  end
334
334
 
335
- if e.class.name == "Redis::CannotConnectError" then
336
- puts "Lost connection to redis."
337
- puts "*** Start or Restart redis and try again."
335
+ if e.class.name == 'Redis::CannotConnectError' then
336
+ puts 'Lost connection to redis.'
337
+ puts '*** Start or Restart redis and try again.'
338
338
  abort();
339
339
  end
340
340
 
341
- errorString = e.message + ". " + e.backtrace.join( ". " )
341
+ errorString = e.message + '. ' + e.backtrace.join('. ')
342
342
  # log errorString
343
343
 
344
344
  @msg.addErrorMsg( @mq.localQueueName, errorString )
@@ -349,7 +349,7 @@ module RServiceBus
349
349
  end
350
350
  end
351
351
  rescue SystemExit, Interrupt
352
- puts "Exiting on request ..."
352
+ puts 'Exiting on request ...'
353
353
  messageLoop = false
354
354
 
355
355
  rescue NoMsgToProcess => e
@@ -374,13 +374,13 @@ module RServiceBus
374
374
  @circuitBreaker.Success
375
375
 
376
376
  rescue Exception => e
377
- if e.message == "SIGTERM" || e.message == "SIGINT" then
378
- puts "Exiting on request ..."
377
+ if e.message == 'SIGTERM' || e.message == 'SIGINT' then
378
+ puts 'Exiting on request ...'
379
379
  messageLoop = false
380
380
  else
381
- puts "*** This is really unexpected."
381
+ puts '*** This is really unexpected.'
382
382
  messageLoop = false
383
- puts "Message: " + e.message
383
+ puts 'Message: ' + e.message
384
384
  puts e.backtrace
385
385
  end
386
386
  end
@@ -395,7 +395,7 @@ module RServiceBus
395
395
  handlerList = @handlerManager.getHandlerListForMsg(msgName)
396
396
 
397
397
 
398
- RServiceBus.rlog "Handler found for: " + msgName
398
+ RServiceBus.rlog 'Handler found for: ' + msgName
399
399
  begin
400
400
  @queueForMsgsToBeSentOnComplete = Array.new
401
401
 
@@ -409,7 +409,7 @@ module RServiceBus
409
409
  raise PropertyNotSet.new( "Property, #{e.message}, not set for, #{handler.class.name}" )
410
410
  rescue Exception => e
411
411
  puts "E #{e.message}"
412
- log "An error occurred in Handler: " + handler.class.name
412
+ log 'An error occurred in Handler: ' + handler.class.name
413
413
  raise e
414
414
  end
415
415
  end
@@ -443,10 +443,10 @@ module RServiceBus
443
443
  # @param [String] serialized_object serialized RServiceBus::Message
444
444
  # @param [String] queueName endpoint to which the msg will be sent
445
445
  def _SendAlreadyWrappedAndSerialised( serialized_object, queueName )
446
- RServiceBus.rlog "Bus._SendAlreadyWrappedAndSerialised"
446
+ RServiceBus.rlog 'Bus._SendAlreadyWrappedAndSerialised'
447
447
 
448
- if !@config.forwardSentMessagesTo.nil? then
449
- @mq.send( @config.forwardSentMessagesTo, serialized_object )
448
+ unless @config.forwardSentMessagesTo.nil? then
449
+ @mq.send(@config.forwardSentMessagesTo, serialized_object)
450
450
  end
451
451
 
452
452
  @mq.send( queueName, serialized_object )
@@ -457,14 +457,14 @@ module RServiceBus
457
457
  # @param [RServiceBus::Message] msg msg to be sent
458
458
  # @param [String] queueName endpoint to which the msg will be sent
459
459
  def _SendNeedsWrapping( msg, queueName, correlationId )
460
- RServiceBus.rlog "Bus._SendNeedsWrapping"
460
+ RServiceBus.rlog 'Bus._SendNeedsWrapping'
461
461
 
462
462
  rMsg = RServiceBus::Message.new( msg, @mq.localQueueName, correlationId )
463
- if queueName.index( "@" ).nil? then
463
+ if queueName.index('@').nil? then
464
464
  q = queueName
465
465
  RServiceBus.rlog "Sending, #{msg.class.name} to, queueName"
466
466
  else
467
- parts = queueName.split( "@" )
467
+ parts = queueName.split('@')
468
468
  rMsg.setRemoteQueueName( parts[0] )
469
469
  rMsg.setRemoteHostName( parts[1] )
470
470
  q = 'transport-out'
@@ -478,7 +478,7 @@ module RServiceBus
478
478
  def sendQueuedMsgs
479
479
  @queueForMsgsToBeSentOnComplete.each do |row|
480
480
  if row['timestamp'].nil? then
481
- self._SendNeedsWrapping( row["msg"], row["queueName"], row["correlationId"] )
481
+ self._SendNeedsWrapping( row['msg'], row['queueName'], row['correlationId'] )
482
482
  else
483
483
  @sendAtManager.Add( row )
484
484
  end
@@ -488,7 +488,7 @@ module RServiceBus
488
488
  def queueMsgForSendOnComplete( msg, queueName, timestamp=nil )
489
489
  correlationId = @sagaData.nil? ? nil : @sagaData.correlationId
490
490
  correlationId = (!@msg.nil? && !@msg.correlationId.nil?) ? @msg.correlationId : correlationId
491
- @queueForMsgsToBeSentOnComplete << Hash["msg", msg, "queueName", queueName, "correlationId", correlationId, "timestamp",timestamp ]
491
+ @queueForMsgsToBeSentOnComplete << Hash['msg', msg, 'queueName', queueName, 'correlationId', correlationId, 'timestamp',timestamp ]
492
492
  end
493
493
 
494
494
  #Sends a msg back across the bus
@@ -497,7 +497,7 @@ module RServiceBus
497
497
  #
498
498
  # @param [RServiceBus::Message] msg msg to be sent
499
499
  def Reply( msg )
500
- RServiceBus.rlog "Reply with: " + msg.class.name + " To: " + @msg.returnAddress
500
+ RServiceBus.rlog 'Reply with: ' + msg.class.name + ' To: ' + @msg.returnAddress
501
501
  @stats.incTotalReply
502
502
 
503
503
  self.queueMsgForSendOnComplete( msg, @msg.returnAddress )
@@ -509,9 +509,9 @@ module RServiceBus
509
509
 
510
510
  return @mq.localQueueName if @handlerManager.canMsgBeHandledLocally(msgName)
511
511
 
512
- log "No end point mapping found for: " + msgName
513
- log "**** Check environment variable MessageEndpointMappings contains an entry named : " + msgName
514
- raise "No end point mapping found for: " + msgName
512
+ log 'No end point mapping found for: ' + msgName
513
+ log '**** Check environment variable MessageEndpointMappings contains an entry named : ' + msgName
514
+ raise 'No end point mapping found for: ' + msgName
515
515
  end
516
516
 
517
517
 
@@ -520,7 +520,7 @@ module RServiceBus
520
520
  #
521
521
  # @param [RServiceBus::Message] msg msg to be sent
522
522
  def Send( msg, timestamp=nil )
523
- RServiceBus.rlog "Bus.Send"
523
+ RServiceBus.rlog 'Bus.Send'
524
524
  @stats.incTotalSent
525
525
 
526
526
  msgName = msg.class.name
@@ -533,7 +533,7 @@ module RServiceBus
533
533
  #
534
534
  # @param [RServiceBus::Message] msg msg to be sent
535
535
  def Publish( msg )
536
- RServiceBus.rlog "Bus.Publish"
536
+ RServiceBus.rlog 'Bus.Publish'
537
537
  @stats.incTotalPublished
538
538
 
539
539
  subscriptions = @subscriptionManager.get(msg.class.name)
@@ -547,7 +547,7 @@ module RServiceBus
547
547
  #
548
548
  # @param [String] eventName event to be subscribes to
549
549
  def Subscribe( eventName )
550
- RServiceBus.rlog "Bus.Subscribe: " + eventName
550
+ RServiceBus.rlog 'Bus.Subscribe: ' + eventName
551
551
 
552
552
  queueName = self.getEndpointForMsg( eventName )
553
553
  subscription = Message_Subscription.new( eventName )