rservicebus2 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/return_messages_to_source_queue +3 -3
- data/bin/rsb_ctl +1 -1
- data/bin/rservicebus2 +3 -3
- data/bin/rservicebus2-transport +4 -5
- data/bin/send_empty_message +6 -7
- data/lib/rservicebus2.rb +59 -0
- data/lib/{rservicebus → rservicebus2}/agent.rb +2 -2
- data/lib/{rservicebus → rservicebus2}/appresource.rb +2 -2
- data/lib/{rservicebus → rservicebus2}/appresource/dir.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/appresource/file.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/appresource/fluiddb.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/appresource_configure.rb +4 -4
- data/lib/{rservicebus → rservicebus2}/audit.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/circuitbreaker.rb +5 -5
- data/lib/{rservicebus → rservicebus2}/config.rb +1 -2
- data/lib/{rservicebus → rservicebus2}/cron_manager.rb +4 -4
- data/lib/{rservicebus → rservicebus2}/endpointmapping.rb +4 -4
- data/lib/{rservicebus → rservicebus2}/errormessage.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/handler_loader.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/handler_manager.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/helper_functions.rb +4 -4
- data/lib/{rservicebus → rservicebus2}/host.rb +4 -4
- data/lib/{rservicebus → rservicebus2}/message.rb +2 -2
- data/lib/{rservicebus → rservicebus2}/message/statisticoutput.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/message/subscription.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/message/verboseoutput.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/monitor.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/monitor/csvdir.rb +7 -7
- data/lib/{rservicebus → rservicebus2}/monitor/dir.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/monitor/dirnotifier.rb +11 -11
- data/lib/{rservicebus → rservicebus2}/monitor/message.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/monitor/xmldir.rb +2 -2
- data/lib/{rservicebus → rservicebus2}/monitor_configure.rb +7 -7
- data/lib/{rservicebus → rservicebus2}/mq.rb +3 -3
- data/lib/{rservicebus → rservicebus2}/mq/beanstalk.rb +2 -2
- data/lib/{rservicebus → rservicebus2}/resource_manager.rb +7 -7
- data/lib/{rservicebus → rservicebus2}/saga/base.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/saga/data.rb +2 -2
- data/lib/{rservicebus → rservicebus2}/saga/manager.rb +24 -26
- data/lib/{rservicebus → rservicebus2}/saga_loader.rb +7 -7
- data/lib/{rservicebus → rservicebus2}/saga_storage.rb +3 -3
- data/lib/{rservicebus → rservicebus2}/saga_storage/dir.rb +2 -3
- data/lib/{rservicebus → rservicebus2}/saga_storage/inmemory.rb +5 -2
- data/lib/{rservicebus → rservicebus2}/sendat_manager.rb +3 -3
- data/lib/{rservicebus → rservicebus2}/sendat_storage.rb +3 -3
- data/lib/{rservicebus → rservicebus2}/sendat_storage/file.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/sendat_storage/inmemory.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/state_manager.rb +3 -3
- data/lib/{rservicebus → rservicebus2}/state_storage.rb +3 -3
- data/lib/{rservicebus → rservicebus2}/state_storage/dir.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/state_storage/inmemory.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/statistic_manager.rb +3 -3
- data/lib/{rservicebus → rservicebus2}/stats.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/subscription_manager.rb +5 -5
- data/lib/{rservicebus → rservicebus2}/subscription_storage.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/subscription_storage/file.rb +1 -1
- data/lib/{rservicebus → rservicebus2}/subscription_storage_configure.rb +2 -2
- data/lib/rservicebus2/test.rb +1 -0
- data/lib/{rservicebus → rservicebus2}/test/bus.rb +2 -2
- data/lib/{rservicebus → rservicebus2}/transporter.rb +16 -16
- data/lib/{rservicebus → rservicebus2}/usermessage/withpayload.rb +1 -1
- metadata +58 -59
- data/lib/rservicebus.rb +0 -59
- data/lib/rservicebus/subscription_storage/redis.rb +0 -69
- data/lib/rservicebus/test.rb +0 -1
@@ -1,14 +1,14 @@
|
|
1
|
-
require '
|
1
|
+
require 'rservicebus2/Monitor/Dir'
|
2
2
|
require 'csv'
|
3
3
|
|
4
|
-
module
|
4
|
+
module RServiceBus2
|
5
5
|
# Pull files and pre-parse as csv
|
6
6
|
class MonitorCsvDir < MonitorDir
|
7
7
|
def check_payload_for_number_of_columns(payload)
|
8
|
-
return if @
|
9
|
-
return unless @
|
8
|
+
return if @query_string_parts.nil?
|
9
|
+
return unless @query_string_parts.key?('cols')
|
10
10
|
|
11
|
-
cols = @
|
11
|
+
cols = @query_string_parts['cols'][0].to_i
|
12
12
|
payload.each_with_index do |row, idx|
|
13
13
|
if row.length != cols
|
14
14
|
fail "Expected number of columns, #{cols}, Actual number of columns,
|
@@ -18,8 +18,8 @@ module RServiceBus
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def check_send_hash
|
21
|
-
if !@
|
22
|
-
flag = @
|
21
|
+
if !@query_string_parts.nil? && @query_string_parts.key?('hash')
|
22
|
+
flag = @query_string_parts['hash'][0]
|
23
23
|
return flag == 'Y'
|
24
24
|
end
|
25
25
|
|
@@ -2,10 +2,10 @@ require 'cgi'
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'pathname'
|
4
4
|
|
5
|
-
module
|
5
|
+
module RServiceBus2
|
6
6
|
# Monitor for Directory
|
7
7
|
class MonitorDirNotifier < Monitor
|
8
|
-
attr_reader :
|
8
|
+
attr_reader :path, :processing_folder, :filter
|
9
9
|
def connect(uri)
|
10
10
|
# Pass the path through the Dir object to check syntax on startup
|
11
11
|
begin
|
@@ -46,25 +46,25 @@ module RServiceBus
|
|
46
46
|
open_folder processing_uri.path
|
47
47
|
unless File.writable?(processing_uri.path)
|
48
48
|
puts "***** Processing Directory is not writable,
|
49
|
-
#{
|
50
|
-
puts "***** Make the directory, #{
|
49
|
+
#{processing_uri.path}."
|
50
|
+
puts "***** Make the directory, #{processing_uri.path},
|
51
51
|
writable and try again."
|
52
52
|
abort
|
53
53
|
end
|
54
54
|
rescue Errno::ENOENT
|
55
55
|
puts "***** Processing Directory does not exist,
|
56
|
-
#{
|
57
|
-
puts "***** Create the directory, #{
|
56
|
+
#{processing_uri.path}."
|
57
|
+
puts "***** Create the directory, #{processing_uri.path}, and try
|
58
58
|
again."
|
59
|
-
puts "***** eg, mkdir #{
|
59
|
+
puts "***** eg, mkdir #{processing_uri.path}"
|
60
60
|
abort
|
61
61
|
rescue Errno::ENOTDIR
|
62
62
|
puts "***** Processing Directory does not point to a directory,
|
63
|
-
#{
|
63
|
+
#{processing_uri.path}."
|
64
64
|
puts "***** Either repoint path to a directory, or remove,
|
65
|
-
#{
|
66
|
-
puts "***** eg, rm #{
|
67
|
-
#{
|
65
|
+
#{processing_uri.path}, and create it as a directory."
|
66
|
+
puts "***** eg, rm #{processing_uri.path} && mkdir
|
67
|
+
#{processing_uri.path}"
|
68
68
|
abort
|
69
69
|
end
|
70
70
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'rservicebus2/monitor'
|
2
|
+
require 'rservicebus2/monitor/message'
|
3
3
|
|
4
|
-
module
|
4
|
+
module RServiceBus2
|
5
5
|
# Configure Monitors for an rservicebus host
|
6
6
|
class ConfigureMonitor
|
7
7
|
# Constructor
|
@@ -46,16 +46,16 @@ module RServiceBus
|
|
46
46
|
monitor = nil
|
47
47
|
case uri.scheme
|
48
48
|
when 'csvdir'
|
49
|
-
require '
|
49
|
+
require 'rservicebus2/monitor/csvdir'
|
50
50
|
monitor = MonitorCsvDir.new(@host, name, uri)
|
51
51
|
when 'xmldir'
|
52
|
-
require '
|
52
|
+
require 'rservicebus2/monitor/xmldir'
|
53
53
|
monitor = MonitorXmlDir.new(@host, name, uri)
|
54
54
|
when 'dir'
|
55
|
-
require '
|
55
|
+
require 'rservicebus2/monitor/dir'
|
56
56
|
monitor = MonitorDir.new(@host, name, uri)
|
57
57
|
when 'dirnotifier'
|
58
|
-
require '
|
58
|
+
require 'rservicebus2/monitor/dirnotifier'
|
59
59
|
monitor = MonitorDirNotifier.new(@host, name, uri)
|
60
60
|
else
|
61
61
|
abort("Scheme, #{uri.scheme}, not recognised when configuring
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'uri'
|
2
2
|
|
3
|
-
module
|
3
|
+
module RServiceBus2
|
4
4
|
class JobTooBigError < StandardError
|
5
5
|
end
|
6
6
|
|
@@ -11,12 +11,12 @@ module RServiceBus
|
|
11
11
|
attr_reader :local_queue_name
|
12
12
|
|
13
13
|
def self.get
|
14
|
-
mq_string =
|
14
|
+
mq_string = RServiceBus2.get_value('RSBMQ', 'beanstalk://localhost')
|
15
15
|
uri = URI.parse(mq_string)
|
16
16
|
|
17
17
|
case uri.scheme
|
18
18
|
when 'beanstalk'
|
19
|
-
require '
|
19
|
+
require 'rservicebus2/MQ/Beanstalk'
|
20
20
|
mq = MQBeanstalk.new(uri)
|
21
21
|
else
|
22
22
|
abort("Scheme, #{uri.scheme}, not recognised when configuring mq,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module RServiceBus2
|
2
2
|
# Coordinate Transactions across resources, handlers, and Sagas
|
3
3
|
class ResourceManager
|
4
4
|
# Constructor
|
@@ -28,7 +28,7 @@ module RServiceBus
|
|
28
28
|
r = @app_resources[name]
|
29
29
|
r._connect
|
30
30
|
r.begin
|
31
|
-
|
31
|
+
RServiceBus2.rlog "Preparing resource: #{name}. Begin"
|
32
32
|
end
|
33
33
|
@current_resources[name] = @app_resources[name]
|
34
34
|
@app_resources[name]
|
@@ -37,10 +37,10 @@ module RServiceBus
|
|
37
37
|
def commit(msg_name)
|
38
38
|
@state_manager.commit
|
39
39
|
@saga_storage.commit
|
40
|
-
|
40
|
+
RServiceBus2.rlog "HandlerManager.commitResourcesUsedToProcessMsg,
|
41
41
|
#{msg_name}"
|
42
42
|
@current_resources.each do |k, v|
|
43
|
-
|
43
|
+
RServiceBus2.rlog "Commit resource, #{v.class.name}"
|
44
44
|
v.commit
|
45
45
|
v.finished
|
46
46
|
end
|
@@ -48,16 +48,16 @@ module RServiceBus
|
|
48
48
|
|
49
49
|
def rollback(msg_name)
|
50
50
|
@saga_storage.rollback
|
51
|
-
|
51
|
+
RServiceBus2.rlog "HandlerManager.rollbackResourcesUsedToProcessMsg,
|
52
52
|
#{msg_name}"
|
53
53
|
@current_resources.each do |k, v|
|
54
54
|
begin
|
55
|
-
|
55
|
+
RServiceBus2.rlog "Rollback resource, #{v.class.name}"
|
56
56
|
v.rollback
|
57
57
|
v.finished
|
58
58
|
rescue StandardError => e1
|
59
59
|
puts "Caught nested exception rolling back, #{v.class.name}, for msg,
|
60
|
-
#{
|
60
|
+
#{msg_name}"
|
61
61
|
puts '****'
|
62
62
|
puts e1.message
|
63
63
|
puts e1.backtrace
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module RServiceBus2
|
2
2
|
# Saga Manager
|
3
3
|
class SagaManager
|
4
4
|
def initialize(host, resource_manager, saga_storage)
|
@@ -14,16 +14,17 @@ module RServiceBus
|
|
14
14
|
|
15
15
|
def get_methods_by_prefix(saga, prefix)
|
16
16
|
list = []
|
17
|
+
d_prefix = prefix.downcase
|
17
18
|
saga.instance_methods.each do |name|
|
18
|
-
|
19
|
-
|
19
|
+
d_name = name.downcase
|
20
|
+
list.push d_name.to_s.sub(d_prefix, '') if d_name.to_s.slice(0, d_prefix.length) == d_prefix
|
20
21
|
end
|
21
22
|
|
22
|
-
list
|
23
|
+
list.uniq # This takes care of a very rare uppercase / lowercase issue
|
23
24
|
end
|
24
25
|
|
25
26
|
def get_start_with_method_names(saga)
|
26
|
-
get_methods_by_prefix(saga, '
|
27
|
+
get_methods_by_prefix(saga, 'startwith_')
|
27
28
|
end
|
28
29
|
|
29
30
|
# setBusAttributeIfRequested
|
@@ -31,22 +32,22 @@ module RServiceBus
|
|
31
32
|
def set_bus_attribute_if_requested(saga)
|
32
33
|
if defined?(saga.bus)
|
33
34
|
saga.bus = @host
|
34
|
-
|
35
|
+
RServiceBus2.log 'Bus attribute set for: ' + saga.class.name
|
35
36
|
end
|
36
37
|
|
37
38
|
self
|
38
39
|
end
|
39
40
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
41
|
+
def interrogate_saga_for_app_resources(saga)
|
42
|
+
RServiceBus2.rlog "Checking app resources for: #{saga.class.name}"
|
43
|
+
RServiceBus2.rlog "If your attribute is not getting set, check that it
|
43
44
|
is in the 'attr_accessor' list"
|
44
45
|
|
45
46
|
@resource_list_by_saga_name[saga.class.name] = []
|
46
47
|
@resource_manager.get_all.each do |k, v|
|
47
48
|
if saga.class.method_defined?(k)
|
48
49
|
@resource_list_by_saga_name[saga.class.name] << k
|
49
|
-
|
50
|
+
RServiceBus2.log "Resource attribute, #{k}, found for: " +
|
50
51
|
saga.class.name
|
51
52
|
end
|
52
53
|
end
|
@@ -62,7 +63,7 @@ module RServiceBus
|
|
62
63
|
@start_with[msg_name] = [] if @start_with[msg_name].nil?
|
63
64
|
@start_with[msg_name] << s
|
64
65
|
|
65
|
-
|
66
|
+
RServiceBus2.log "Registered, #{saga.name}, to startwith, #{msg_name}", true
|
66
67
|
end
|
67
68
|
|
68
69
|
@saga[saga.name] = s
|
@@ -76,7 +77,7 @@ module RServiceBus
|
|
76
77
|
|
77
78
|
@resource_list_by_saga_name[saga.class.name].each do |k, v|
|
78
79
|
saga.instance_variable_set("@#{k}", @resource_manager.get(k).get_resource)
|
79
|
-
|
80
|
+
RServiceBus2.rlog "App resource attribute, #{k}, set for: " + saga.class.name
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -84,14 +85,15 @@ module RServiceBus
|
|
84
85
|
@resources_used = {}
|
85
86
|
handled = false
|
86
87
|
msg = rmsg.msg
|
88
|
+
msg_class_name = msg.class.name.downcase
|
87
89
|
|
88
|
-
|
89
|
-
unless @start_with[
|
90
|
-
@start_with[
|
91
|
-
data =
|
90
|
+
RServiceBus2.log "SagaManager, started processing, #{msg_class_name}", true
|
91
|
+
unless @start_with[msg_class_name].nil?
|
92
|
+
@start_with[msg_class_name].each do |saga|
|
93
|
+
data = SagaData.new(saga)
|
92
94
|
@saga_storage.set(data)
|
93
95
|
|
94
|
-
method_name = "
|
96
|
+
method_name = "startwith_#{msg_class_name}"
|
95
97
|
process_msg(saga, data, method_name, msg)
|
96
98
|
|
97
99
|
handled = true
|
@@ -102,25 +104,21 @@ module RServiceBus
|
|
102
104
|
return false if rmsg.correlation_id.nil?
|
103
105
|
data = @saga_storage.get(rmsg.correlation_id)
|
104
106
|
return handled if data.nil?
|
105
|
-
method_name = "handle_#{
|
107
|
+
method_name = "handle_#{msg_class_name}"
|
106
108
|
saga = @saga[data.saga_class_name]
|
107
109
|
process_msg(saga, data, method_name, msg)
|
108
110
|
|
109
|
-
|
111
|
+
true
|
110
112
|
end
|
111
113
|
|
112
|
-
def process_msg(saga, data,
|
114
|
+
def process_msg(saga, data, method_name, msg)
|
113
115
|
@host.saga_data = data
|
114
116
|
saga.data = data
|
115
117
|
prep_saga(saga)
|
116
118
|
|
117
|
-
if saga.class.method_defined?(method_name)
|
118
|
-
saga.send method_name, msg
|
119
|
-
end
|
119
|
+
saga.send(method_name, msg) if saga.class.method_defined?(method_name)
|
120
120
|
|
121
|
-
if data.finished == true
|
122
|
-
@saga_storage.delete data.correlation_id
|
123
|
-
end
|
121
|
+
@saga_storage.delete(data.correlation_id) if data.finished == true
|
124
122
|
|
125
123
|
@host.saga_data = nil
|
126
124
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module RServiceBus2
|
2
2
|
# Given a directory, this class is responsible loading Sagas
|
3
3
|
class SagaLoader
|
4
4
|
attr_reader :saga_list
|
@@ -55,16 +55,16 @@ module RServiceBus
|
|
55
55
|
# @returns [RServiceBus::Saga] saga
|
56
56
|
def load_saga(file_path, saga_name)
|
57
57
|
if @list_of_loaded_paths.key?(file_path)
|
58
|
-
|
58
|
+
RServiceBus2.log "Not reloading, #{file_path}"
|
59
59
|
return
|
60
60
|
end
|
61
61
|
|
62
62
|
begin
|
63
|
-
|
64
|
-
|
63
|
+
RServiceBus2.rlog 'file_path: ' + file_path
|
64
|
+
RServiceBus2.rlog 'saga_name: ' + saga_name
|
65
65
|
|
66
66
|
saga = load_saga_from_file(saga_name, file_path)
|
67
|
-
|
67
|
+
RServiceBus2.log 'Loaded Saga: ' + saga_name
|
68
68
|
|
69
69
|
@saga_manager.register_saga(saga)
|
70
70
|
|
@@ -83,7 +83,7 @@ module RServiceBus
|
|
83
83
|
def get_list_of_files_for_dir(path)
|
84
84
|
list = Dir[path + '/*']
|
85
85
|
|
86
|
-
|
86
|
+
RServiceBus2.rlog "SagaLoader.getListOfFilesForDir. path: #{path},
|
87
87
|
list: #{list}"
|
88
88
|
|
89
89
|
list
|
@@ -103,7 +103,7 @@ module RServiceBus
|
|
103
103
|
# Entry point for loading Sagas
|
104
104
|
# @param [String] base_dir directory to check - should not have trailing slash
|
105
105
|
def load_sagas_from_path(base_dir)
|
106
|
-
|
106
|
+
RServiceBus2.rlog "SagaLoader.loadSagasFromPath. base_dir: #{base_dir}"
|
107
107
|
|
108
108
|
get_list_of_files_for_dir(base_dir).each do |file_path|
|
109
109
|
unless filePath.end_with?('.')
|
@@ -1,13 +1,13 @@
|
|
1
|
-
module
|
1
|
+
module RServiceBus2
|
2
2
|
# Saga Storage
|
3
3
|
class SagaStorage
|
4
4
|
def self.get(uri)
|
5
5
|
case uri.scheme
|
6
6
|
when 'dir'
|
7
|
-
require '
|
7
|
+
require 'rservicebus2/saga_storage/dir'
|
8
8
|
return SagaStorageDir.new(uri)
|
9
9
|
when 'inmem'
|
10
|
-
require '
|
10
|
+
require 'rservicebus2/saga_storage/inmemory'
|
11
11
|
return SagaStorageInMemory.new(uri)
|
12
12
|
else
|
13
13
|
abort("Scheme, #{uri.scheme}, not recognised when configuring
|
@@ -1,11 +1,10 @@
|
|
1
|
-
module
|
2
|
-
|
1
|
+
module RServiceBus2
|
3
2
|
# Saga Storage Dir
|
4
3
|
class SagaStorageDir
|
5
4
|
def initialize(uri)
|
6
5
|
@saga_dir = uri.path
|
7
6
|
|
8
|
-
|
7
|
+
Dir.new(@saga_dir)
|
9
8
|
unless File.writable?(@saga_dir)
|
10
9
|
puts "***** Directory is not writable, #{@saga_dir}."
|
11
10
|
puts "***** Make the directory, #{@saga_dir}, writable and try again."
|