rservicebus2 0.2.6 → 0.2.11
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.
- checksums.yaml +4 -4
- data/lib/rservicebus2.rb +6 -4
- data/lib/rservicebus2/agent.rb +7 -4
- data/lib/rservicebus2/appresource.rb +8 -9
- data/lib/rservicebus2/appresource/awsdynamodb.rb +3 -3
- data/lib/rservicebus2/appresource/awss3.rb +3 -3
- data/lib/rservicebus2/appresource/awssqs.rb +27 -0
- data/lib/rservicebus2/appresource/dir.rb +3 -0
- data/lib/rservicebus2/appresource/file.rb +2 -0
- data/lib/rservicebus2/appresource/fluiddb.rb +3 -0
- data/lib/rservicebus2/appresource/fluiddb2.rb +3 -1
- data/lib/rservicebus2/appresource_configure.rb +11 -4
- data/lib/rservicebus2/audit.rb +4 -2
- data/lib/rservicebus2/circuitbreaker.rb +4 -2
- data/lib/rservicebus2/config.rb +44 -35
- data/lib/rservicebus2/cron_manager.rb +6 -1
- data/lib/rservicebus2/endpointmapping.rb +20 -14
- data/lib/rservicebus2/errormessage.rb +3 -2
- data/lib/rservicebus2/handler_loader.rb +35 -28
- data/lib/rservicebus2/handler_manager.rb +31 -25
- data/lib/rservicebus2/helper_functions.rb +20 -15
- data/lib/rservicebus2/host.rb +63 -124
- data/lib/rservicebus2/message.rb +11 -19
- data/lib/rservicebus2/message/statisticoutput.rb +2 -0
- data/lib/rservicebus2/message/subscription.rb +2 -0
- data/lib/rservicebus2/message/verboseoutput.rb +2 -0
- data/lib/rservicebus2/monitor.rb +7 -8
- data/lib/rservicebus2/monitor/awss3.rb +3 -1
- data/lib/rservicebus2/monitor/awssqs.rb +34 -0
- data/lib/rservicebus2/monitor/dir.rb +25 -23
- data/lib/rservicebus2/monitor/dirnotifier.rb +3 -0
- data/lib/rservicebus2/monitor/message.rb +2 -0
- data/lib/rservicebus2/monitor/xmldir.rb +2 -0
- data/lib/rservicebus2/monitor_configure.rb +47 -34
- data/lib/rservicebus2/mq.rb +27 -30
- data/lib/rservicebus2/mq/beanstalk.rb +5 -1
- data/lib/rservicebus2/resource_manager.rb +14 -19
- data/lib/rservicebus2/saga/data.rb +1 -1
- data/lib/rservicebus2/saga/manager.rb +2 -2
- data/lib/rservicebus2/saga_loader.rb +27 -24
- data/lib/rservicebus2/saga_storage.rb +5 -4
- data/lib/rservicebus2/sendat_manager.rb +5 -3
- data/lib/rservicebus2/sendat_storage.rb +5 -3
- data/lib/rservicebus2/sendat_storage/file.rb +6 -2
- data/lib/rservicebus2/sendat_storage/inmemory.rb +2 -0
- data/lib/rservicebus2/state_manager.rb +5 -4
- data/lib/rservicebus2/state_storage.rb +7 -6
- data/lib/rservicebus2/statistic_manager.rb +7 -3
- data/lib/rservicebus2/subscription_manager.rb +7 -5
- data/lib/rservicebus2/subscription_storage.rb +6 -5
- data/lib/rservicebus2/subscription_storage/file.rb +5 -18
- data/lib/rservicebus2/subscription_storage_configure.rb +2 -0
- data/lib/rservicebus2/transporter.rb +63 -52
- metadata +19 -18
- data/lib/rservicebus2/stats.rb +0 -68
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'parse-cron'
|
2
4
|
|
3
5
|
module RServiceBus2
|
@@ -27,7 +29,8 @@ module RServiceBus2
|
|
27
29
|
@msg_names.each do |n|
|
28
30
|
list << n if Globber.new(name) =~ n
|
29
31
|
end
|
30
|
-
|
32
|
+
raise NoMatchingMsgForCron, name if list.empty?
|
33
|
+
|
31
34
|
list
|
32
35
|
end
|
33
36
|
|
@@ -44,6 +47,7 @@ module RServiceBus2
|
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
50
|
+
# rubocop:disable Metrics/MethodLength
|
47
51
|
def initialize(host, msg_names = [])
|
48
52
|
@bus = host
|
49
53
|
@msg_names = msg_names
|
@@ -61,6 +65,7 @@ module RServiceBus2
|
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
68
|
+
# rubocop:enable Metrics/MethodLength
|
64
69
|
|
65
70
|
def run
|
66
71
|
now = Time.now
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RServiceBus2
|
2
4
|
# Marshals data for message end points
|
3
5
|
# Expected format: <msg mame 1>:<end point 1>;<msg mame 2>:<end point 2>
|
@@ -6,16 +8,17 @@ module RServiceBus2
|
|
6
8
|
RServiceBus2.get_value(name)
|
7
9
|
end
|
8
10
|
|
9
|
-
def log(string, _ver
|
11
|
+
def log(string, _ver: false)
|
10
12
|
RServiceBus2.log(string)
|
11
13
|
end
|
12
14
|
|
15
|
+
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
13
16
|
def configure_mapping(mapping)
|
14
17
|
match = mapping.match(/(.+):(.+)/)
|
15
18
|
if match.nil?
|
16
|
-
log 'Mapping string provided is invalid'
|
17
|
-
|
18
|
-
|
19
|
+
log 'Mapping string provided is invalid\n' \
|
20
|
+
"The entire mapping string is: #{mapping}\n" \
|
21
|
+
"*** Could not find ':' in mapping entry, #{line}\n"
|
19
22
|
exit
|
20
23
|
end
|
21
24
|
|
@@ -23,16 +26,18 @@ module RServiceBus2
|
|
23
26
|
@endpoints[match[1]] = match[2]
|
24
27
|
|
25
28
|
@queue_name_list.each do |q|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
next unless q != match[2] && q.downcase == match[2].downcase
|
30
|
+
|
31
|
+
log('*** Two queues specified with only case sensitive difference.')
|
32
|
+
log("*** #{q} != #{match[2]}")
|
33
|
+
log('*** If you meant these queues to be the same, please match case
|
34
|
+
and restart the bus.')
|
32
35
|
end
|
33
36
|
@queue_name_list << match[2]
|
34
37
|
end
|
38
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
35
39
|
|
40
|
+
# rubocop:disable Metrics/MethodLength
|
36
41
|
def configure(local_queue_name = nil)
|
37
42
|
log('EndpointMapping.Configure')
|
38
43
|
|
@@ -40,9 +45,9 @@ module RServiceBus2
|
|
40
45
|
@queue_name_list << local_queue_name unless local_queue_name.nil?
|
41
46
|
|
42
47
|
unless get_value('MESSAGE_ENDPOINT_MAPPING').nil?
|
43
|
-
log
|
44
|
-
|
45
|
-
on the end"
|
48
|
+
log '*** MESSAGE_ENDPOINT_MAPPING environment variable was detected\n' \
|
49
|
+
"*** You may have intended MESSAGE_ENDPOINT_MAPPINGS, note the 'S'
|
50
|
+
on the end"
|
46
51
|
end
|
47
52
|
|
48
53
|
mappings = get_value('MESSAGE_ENDPOINT_MAPPINGS')
|
@@ -54,6 +59,7 @@ module RServiceBus2
|
|
54
59
|
|
55
60
|
self
|
56
61
|
end
|
62
|
+
# rubocop:enable Metrics/MethodLength
|
57
63
|
|
58
64
|
def initialize
|
59
65
|
@endpoints = {}
|
@@ -65,7 +71,7 @@ module RServiceBus2
|
|
65
71
|
nil
|
66
72
|
end
|
67
73
|
|
68
|
-
def
|
74
|
+
def subscription_endpoints
|
69
75
|
@endpoints.keys.select { |el| el.end_with?('Event') }
|
70
76
|
end
|
71
77
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module RServiceBus2
|
3
4
|
# Error Message
|
4
5
|
class ErrorMessage
|
5
6
|
attr_reader :occurredat, :source_queue, :error_msg
|
6
7
|
|
7
8
|
def initialize(source_queue, error_msg)
|
8
|
-
@occurredat =
|
9
|
+
@occurredat = Time.now
|
9
10
|
|
10
11
|
@source_queue = source_queue
|
11
12
|
@error_msg = error_msg
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RServiceBus2
|
2
4
|
# Given a directory, this class is responsible for finding
|
3
5
|
# msgnames,
|
4
6
|
# handlernames, and
|
5
7
|
# loading handlers
|
6
8
|
class HandlerLoader
|
7
|
-
attr_reader :handlerList
|
9
|
+
# attr_reader :handlerList - 8 May 2021
|
8
10
|
|
9
11
|
# Constructor
|
10
12
|
#
|
@@ -22,12 +24,11 @@ module RServiceBus2
|
|
22
24
|
# Cleans the given path to ensure it can be used for as a parameter for the require statement.
|
23
25
|
# @param [String] file_path the path to be cleaned
|
24
26
|
def get_require_path(file_path)
|
25
|
-
file_path =
|
27
|
+
file_path = "./#{file_path}" unless file_path.start_with?('/')
|
26
28
|
|
27
29
|
return file_path.sub('.rb', '') if File.exist?(file_path)
|
28
30
|
|
29
|
-
abort(
|
30
|
-
doesn't exist")
|
31
|
+
abort("Filepath, #{file_path}, given for messagehandler require doesn't exist")
|
31
32
|
end
|
32
33
|
|
33
34
|
# Instantiate the handler named in handlerName from the file name in
|
@@ -38,6 +39,7 @@ module RServiceBus2
|
|
38
39
|
# @param [String] handler_name name of the handler to instantiate
|
39
40
|
# @param [String] file_path the path to the file to be loaded
|
40
41
|
# @return [RServiceBus2::Handler] the loader
|
42
|
+
# rubocop:disable Metrics/MethodLength
|
41
43
|
def load_handler_from_file(handler_name, file_path)
|
42
44
|
require_path = get_require_path(file_path)
|
43
45
|
|
@@ -45,22 +47,22 @@ module RServiceBus2
|
|
45
47
|
begin
|
46
48
|
handler = Object.const_get(handler_name).new
|
47
49
|
rescue StandardError => e
|
48
|
-
puts
|
49
|
-
|
50
|
-
|
51
|
-
handler_name
|
52
|
-
puts '( In case its not that )'
|
50
|
+
puts "Expected class name: #{handler_name}, not found after require: #{require_path}\n" \
|
51
|
+
"**** Check in #{file_path} that the class is named: #{handler_name}\n" \
|
52
|
+
'( In case its not that )'
|
53
53
|
raise e
|
54
54
|
end
|
55
55
|
|
56
56
|
handler
|
57
57
|
end
|
58
|
+
# rubocop:enable Metrics/MethodLength
|
58
59
|
|
59
60
|
# Wrapper function
|
60
61
|
#
|
61
62
|
# @param [String] file_path
|
62
63
|
# @param [String] handler_name
|
63
64
|
# @returns [RServiceBus2::Handler] handler
|
65
|
+
# rubocop:disable Metrics/MethodLength
|
64
66
|
def load_handler(msg_name, file_path, handler_name)
|
65
67
|
if @list_of_loaded_paths.key?(file_path)
|
66
68
|
RServiceBus2.log "Not reloading, #{file_path}"
|
@@ -68,29 +70,30 @@ module RServiceBus2
|
|
68
70
|
end
|
69
71
|
|
70
72
|
begin
|
71
|
-
RServiceBus2.rlog
|
72
|
-
RServiceBus2.rlog
|
73
|
+
RServiceBus2.rlog "file_path: #{file_path}"
|
74
|
+
RServiceBus2.rlog "handler_name: #{handler_name}"
|
73
75
|
|
74
76
|
handler = load_handler_from_file(handler_name, file_path)
|
75
|
-
RServiceBus2.log
|
77
|
+
RServiceBus2.log "Loaded Handler: #{handler_name}"
|
76
78
|
|
77
79
|
@handler_manager.add_handler(msg_name, handler)
|
78
80
|
|
79
81
|
@list_of_loaded_paths[file_path] = 1
|
80
82
|
rescue StandardError => e
|
81
|
-
puts
|
83
|
+
puts "Exception loading handler from file: #{file_path}"
|
82
84
|
puts e.message
|
83
85
|
puts e.backtrace[0]
|
84
86
|
abort
|
85
87
|
end
|
86
88
|
end
|
89
|
+
# rubocop:enable Metrics/MethodLength
|
87
90
|
|
88
91
|
# This method is overloaded for unit tests
|
89
92
|
#
|
90
93
|
# @param [String] path directory to check
|
91
94
|
# @return [Array] a list of paths to files found in the given path
|
92
95
|
def get_list_of_files_for_dir(path)
|
93
|
-
list = Dir[path
|
96
|
+
list = Dir["#{path}/*"]
|
94
97
|
RServiceBus2.rlog "HandlerLoader.getListOfFilesForDir. path: #{path},
|
95
98
|
list: #{list}"
|
96
99
|
list
|
@@ -105,14 +108,14 @@ module RServiceBus2
|
|
105
108
|
def load_handlers_from_second_level_path(msg_name, base_dir)
|
106
109
|
get_list_of_files_for_dir(base_dir).each do |file_path|
|
107
110
|
next if file_path.end_with?('.')
|
111
|
+
next unless !File.directory?(file_path) && File.extname(file_path) == '.rb'
|
108
112
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
+
file_name = File.basename(file_path).sub('.rb', '')
|
114
|
+
# Classify
|
115
|
+
handler_name = "message_handler_#{msg_name}_#{file_name}"
|
116
|
+
.gsub(/(?<=_|^)(\w)/) { Regexp.last_match(1).upcase }.gsub(/(?:_)(\w)/, '\1')
|
113
117
|
|
114
|
-
|
115
|
-
end
|
118
|
+
load_handler(msg_name, file_path, handler_name)
|
116
119
|
end
|
117
120
|
|
118
121
|
self
|
@@ -130,22 +133,26 @@ module RServiceBus2
|
|
130
133
|
# Load top level handlers from the given directory
|
131
134
|
#
|
132
135
|
# @param [String] baseDir directory to check - should not have trailing slash
|
136
|
+
# rubocop:disable Metrics/MethodLength
|
133
137
|
def load_handlers_from_top_level_path(base_dir)
|
134
138
|
RServiceBus2.rlog "HandlerLoader.loadHandlersFromTopLevelPath. baseDir: #{base_dir}"
|
135
139
|
get_list_of_files_for_dir(base_dir).each do |file_path|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
next if file_path.end_with?('.')
|
141
|
+
|
142
|
+
msg_name = get_msg_name(file_path)
|
143
|
+
if File.directory?(file_path)
|
144
|
+
load_handlers_from_second_level_path(msg_name, file_path)
|
145
|
+
else
|
146
|
+
# Classify
|
147
|
+
handler_name = "message_handler_#{msg_name}"
|
148
|
+
.gsub(/(?<=_|^)(\w)/) { Regexp.last_match(1).upcase }.gsub(/(?:_)(\w)/, '\1')
|
149
|
+
load_handler(msg_name, file_path, handler_name)
|
144
150
|
end
|
145
151
|
end
|
146
152
|
|
147
153
|
self
|
148
154
|
end
|
155
|
+
# rubocop:enable Metrics/MethodLength
|
149
156
|
|
150
157
|
# Entry point for loading handlers
|
151
158
|
#
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RServiceBus2
|
2
4
|
# Given a directory, this class is responsible for finding
|
3
5
|
# msgnames,
|
@@ -20,10 +22,10 @@ module RServiceBus2
|
|
20
22
|
# setBusAttributeIfRequested
|
21
23
|
#
|
22
24
|
# @param [RServiceBus2::Handler] handler
|
23
|
-
def
|
25
|
+
def conditionally_set_bus_attribute(handler)
|
24
26
|
if defined?(handler.bus)
|
25
27
|
handler.bus = @host
|
26
|
-
RServiceBus2.log
|
28
|
+
RServiceBus2.log "Bus attribute set for: #{handler.class.name}"
|
27
29
|
end
|
28
30
|
|
29
31
|
self
|
@@ -32,10 +34,10 @@ module RServiceBus2
|
|
32
34
|
# setStateAttributeIfRequested
|
33
35
|
#
|
34
36
|
# @param [RServiceBus2::Handler] handler
|
35
|
-
def
|
37
|
+
def conditionally_set_state_attribute(handler)
|
36
38
|
if defined?(handler.state)
|
37
39
|
handler.state = @state_manager.get(handler)
|
38
|
-
RServiceBus2.log
|
40
|
+
RServiceBus2.log "Bus attribute set for: #{handler.class.name}"
|
39
41
|
end
|
40
42
|
|
41
43
|
self
|
@@ -50,29 +52,29 @@ module RServiceBus2
|
|
50
52
|
self
|
51
53
|
end
|
52
54
|
|
55
|
+
# rubocop:disable Metrics/AbcSize
|
53
56
|
def interrogate_handler_for_app_resources(handler)
|
54
|
-
RServiceBus2.rlog "Checking app resources for: #{handler.class.name}"
|
55
|
-
|
57
|
+
RServiceBus2.rlog "Checking app resources for: #{handler.class.name}\n" \
|
58
|
+
"If your attribute is not getting set, check that it is in the 'attr_accessor' list"
|
56
59
|
|
57
60
|
@resource_list_by_handler_name[handler.class.name] = []
|
58
|
-
@resource_manager.
|
61
|
+
@resource_manager.all.each do |k, _v|
|
59
62
|
next unless handler.class.method_defined?(k)
|
60
63
|
|
61
64
|
@resource_list_by_handler_name[handler.class.name] << k
|
62
|
-
RServiceBus2.log "Resource attribute, #{k}, found for: "
|
63
|
-
handler.class.name
|
65
|
+
RServiceBus2.log "Resource attribute, #{k}, found for: #{handler.class.name}"
|
64
66
|
end
|
65
|
-
|
66
|
-
self
|
67
67
|
end
|
68
|
+
# rubocop:enable Metrics/AbcSize
|
68
69
|
|
69
70
|
def add_handler(lc_msg_name, handler)
|
70
|
-
|
71
|
+
# Turn snake_case string to CamelCase
|
72
|
+
msg_name = lc_msg_name.gsub(/(?<=_|^)(\w)/) { Regexp.last_match(1).upcase }.gsub(/(?:_)(\w)/, '\1')
|
71
73
|
@handler_list[msg_name] = [] if @handler_list[msg_name].nil?
|
72
|
-
return unless @handler_list[msg_name].index{ |x| x.
|
74
|
+
return unless @handler_list[msg_name].index { |x| x.instance_of(handler) }.nil?
|
73
75
|
|
74
76
|
@handler_list[msg_name] << handler
|
75
|
-
|
77
|
+
conditionally_set_bus_attribute(handler)
|
76
78
|
check_if_state_attribute_requested(handler)
|
77
79
|
interrogate_handler_for_app_resources(handler)
|
78
80
|
end
|
@@ -86,28 +88,32 @@ module RServiceBus2
|
|
86
88
|
|
87
89
|
list = []
|
88
90
|
@handler_list[msg_name].each do |handler|
|
89
|
-
|
91
|
+
unless @resource_list_by_handler_name[handler.class.name].nil?
|
92
|
+
list += @resource_list_by_handler_name[handler.class.name]
|
93
|
+
end
|
90
94
|
end
|
91
95
|
list.uniq!
|
92
96
|
end
|
93
97
|
|
94
|
-
|
98
|
+
# rubocop:disable Metrics/AbcSize
|
99
|
+
def conditionally_set_resources_for_handlers(msg_name)
|
95
100
|
@handler_list[msg_name].each do |handler|
|
96
|
-
|
97
|
-
|
101
|
+
conditionally_set_state_attribute(handler)
|
98
102
|
next if @resource_list_by_handler_name[handler.class.name].nil?
|
103
|
+
|
99
104
|
@resource_list_by_handler_name[handler.class.name].each do |k|
|
100
|
-
handler.instance_variable_set("@#{k}", @resource_manager.get(k).
|
101
|
-
RServiceBus2.rlog "App resource attribute, #{k}, set for:
|
105
|
+
handler.instance_variable_set("@#{k}", @resource_manager.get(k).resource)
|
106
|
+
RServiceBus2.rlog "App resource attribute, #{k}, set for: #{handler.class.name}"
|
102
107
|
end
|
103
108
|
end
|
104
109
|
end
|
110
|
+
# rubocop:enable Metrics/AbcSize
|
105
111
|
|
106
112
|
def get_handler_list_for_msg(msg_name)
|
107
113
|
return [] if @handler_list[msg_name].nil?
|
108
114
|
|
109
|
-
list = get_list_of_resources_needed_to_process_msg(msg_name)
|
110
|
-
|
115
|
+
# list = get_list_of_resources_needed_to_process_msg(msg_name)
|
116
|
+
conditionally_set_resources_for_handlers(msg_name)
|
111
117
|
|
112
118
|
@handler_list[msg_name]
|
113
119
|
end
|
@@ -116,16 +122,16 @@ module RServiceBus2
|
|
116
122
|
@handler_list.key?(msg_name)
|
117
123
|
end
|
118
124
|
|
119
|
-
def
|
125
|
+
def stats
|
120
126
|
list = []
|
121
|
-
@handler_list.each do |
|
127
|
+
@handler_list.each do |_k, v|
|
122
128
|
list << v.inspect
|
123
129
|
end
|
124
130
|
|
125
131
|
list
|
126
132
|
end
|
127
133
|
|
128
|
-
def
|
134
|
+
def msg_names
|
129
135
|
@handler_list.keys
|
130
136
|
end
|
131
137
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Helper functions
|
1
4
|
module RServiceBus2
|
2
5
|
def self.convert_dto_to_hash(obj)
|
3
6
|
hash = {}
|
@@ -11,14 +14,14 @@ module RServiceBus2
|
|
11
14
|
convert_dto_to_hash(obj).to_json
|
12
15
|
end
|
13
16
|
|
14
|
-
def self.log(string, ver
|
17
|
+
def self.log(string, ver: false)
|
15
18
|
return if check_environment_variable('TESTING')
|
16
19
|
|
17
20
|
type = ver ? 'VERB' : 'INFO'
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
return unless check_environment_variable('VERBOSE') || !ver
|
22
|
+
|
23
|
+
timestamp = Time.new.strftime('%Y-%m-%d %H:%M:%S')
|
24
|
+
puts "[#{type}] #{timestamp} :: #{string}"
|
22
25
|
end
|
23
26
|
|
24
27
|
def self.rlog(string)
|
@@ -35,11 +38,12 @@ module RServiceBus2
|
|
35
38
|
end
|
36
39
|
|
37
40
|
def self.get_value(name, default = nil)
|
38
|
-
value =
|
41
|
+
value = ENV[name].nil? || ENV[name] == '' ? default : ENV[name]
|
39
42
|
log "Env value: #{name}: #{value}"
|
40
43
|
value
|
41
44
|
end
|
42
45
|
|
46
|
+
# rubocop:disable Metrics/MethodLength
|
43
47
|
def self.send_msg(msg, response_queue = 'agent')
|
44
48
|
require 'rservicebus2/endpointmapping'
|
45
49
|
endpoint_mapping = EndpointMapping.new
|
@@ -50,15 +54,13 @@ module RServiceBus2
|
|
50
54
|
agent = RServiceBus2::Agent.new
|
51
55
|
Audit.new(agent).audit_to_queue(msg)
|
52
56
|
agent.send_msg(msg, queue_name, response_queue)
|
53
|
-
|
54
57
|
rescue QueueNotFoundForMsg => e
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
msg = "#{msg}*** MESSAGE_ENDPOINT_MAPPINGS=#{e.message}:<QueueName>\n"
|
60
|
-
raise StandardError, msg
|
58
|
+
raise StandardError, '' \
|
59
|
+
"*** Queue not found for, #{e.message}\n" \
|
60
|
+
"*** Ensure you have an environment variable set for this Message Type, eg, \n" \
|
61
|
+
"*** MESSAGE_ENDPOINT_MAPPINGS=#{e.message}:<QueueName>\n"
|
61
62
|
end
|
63
|
+
# rubocop:enable Metrics/MethodLength
|
62
64
|
|
63
65
|
def self.check_for_reply(queue_name)
|
64
66
|
ENV['RSBMQ'] = 'beanstalk://localhost' if ENV['RSBMQ'].nil?
|
@@ -74,12 +76,15 @@ module RServiceBus2
|
|
74
76
|
#{caller[0]}. #{string}"
|
75
77
|
end
|
76
78
|
|
79
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
77
80
|
def self.check_environment_variable(string)
|
78
|
-
return false if ENV[string].nil?
|
81
|
+
return false if ENV[string].nil? || ENV[string] == ''
|
79
82
|
return true if ENV[string] == true || ENV[string] =~ (/(true|t|yes|y|1)$/i)
|
80
83
|
return false if ENV[string] == false ||
|
81
84
|
ENV[string].nil? ||
|
82
85
|
ENV[string] =~ (/(false|f|no|n|0)$/i)
|
83
|
-
|
86
|
+
|
87
|
+
raise ArgumentError, "invalid value for Environment Variable: \"#{string}\""
|
84
88
|
end
|
89
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
85
90
|
end
|