rservicebus2 0.2.9 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rservicebus2/agent.rb +2 -2
- data/lib/rservicebus2/errormessage.rb +1 -1
- data/lib/rservicebus2/host.rb +4 -4
- data/lib/rservicebus2/message.rb +9 -19
- data/lib/rservicebus2/monitor/dir.rb +1 -1
- data/lib/rservicebus2/mq/beanstalk.rb +5 -1
- data/lib/rservicebus2/saga/data.rb +1 -1
- data/lib/rservicebus2/sendat_manager.rb +5 -3
- data/lib/rservicebus2/sendat_storage.rb +5 -3
- data/lib/rservicebus2/sendat_storage/file.rb +7 -2
- data/lib/rservicebus2/sendat_storage/inmemory.rb +2 -0
- data/lib/rservicebus2/state_manager.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd8b2dfcd1227fbfa6285ecee4096a893a6f034c9bb7106564da2423a7344c8e
|
4
|
+
data.tar.gz: de0f4dbbf5ac8f3b683485577a73f4f40d19f10705b2d487e13dbf2acd637ef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0214102bf52760d3b773ef194cde8718ba6113637f65e4791329109b3ba3fbe05ab9b94e4f9dffc0d39d55f9e2530d5ddfd64629b9ed6916f5cf2b9ee4d38f2
|
7
|
+
data.tar.gz: 329306b143ee14af68664432dfa7d541f82ef55d1695dd16f77ebb03dd3ffbd28a7bd19f1c6a116d2220bfad302903da6569b717b36e91980bb334eb1f2773d8
|
data/lib/rservicebus2/agent.rb
CHANGED
@@ -33,8 +33,8 @@ module RServiceBus2
|
|
33
33
|
q = queue_name
|
34
34
|
else
|
35
35
|
parts = queueName.split('@')
|
36
|
-
msg.
|
37
|
-
msg.
|
36
|
+
msg.remote_queue_name = parts[0]
|
37
|
+
msg.remote_host_name = parts[1]
|
38
38
|
q = 'transport-out'
|
39
39
|
end
|
40
40
|
|
data/lib/rservicebus2/host.rb
CHANGED
@@ -339,8 +339,8 @@ module RServiceBus2
|
|
339
339
|
RServiceBus2.rlog "Sending, #{msg.class.name} to, #{queue_name}"
|
340
340
|
else
|
341
341
|
parts = queue_name.split('@')
|
342
|
-
r_msg.
|
343
|
-
r_msg.
|
342
|
+
r_msg.remote_queue_name = parts[0]
|
343
|
+
r_msg.remote_host_name = parts[1]
|
344
344
|
q = 'transport-out'
|
345
345
|
RServiceBus2.rlog "Sending, #{msg.class.name} to, #{queue_name}, via #{q}"
|
346
346
|
end
|
@@ -370,11 +370,11 @@ module RServiceBus2
|
|
370
370
|
# Reply queues are specified in each msg. It works like
|
371
371
|
# email, where the reply address can actually be anywhere
|
372
372
|
# @param [RServiceBus2::Message] msg msg to be sent
|
373
|
-
def reply(msg)
|
373
|
+
def reply(msg, timestamp = nil)
|
374
374
|
RServiceBus2.rlog "Reply with: #{msg.class.name} To: #{@msg.return_address}"
|
375
375
|
@stats.inc_total_reply
|
376
376
|
|
377
|
-
queue_msg_for_send_on_complete(msg, @msg.return_address)
|
377
|
+
queue_msg_for_send_on_complete(msg, @msg.return_address, timestamp)
|
378
378
|
end
|
379
379
|
|
380
380
|
def get_endpoint_for_msg(msg_name)
|
data/lib/rservicebus2/message.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'zlib'
|
2
4
|
require 'yaml'
|
3
5
|
require 'uuidtools'
|
@@ -5,10 +7,12 @@ require 'uuidtools'
|
|
5
7
|
module RServiceBus2
|
6
8
|
# This is the top level message that is passed around the bus
|
7
9
|
class Message
|
8
|
-
attr_reader :return_address, :msg_id,
|
10
|
+
attr_reader :return_address, :msg_id,
|
9
11
|
:last_error_source_queue, :last_error_string, :correlation_id,
|
10
12
|
:sendat, :error_list
|
11
13
|
|
14
|
+
attr_accessor :remote_host_name, :remote_queue_name, :send_at
|
15
|
+
|
12
16
|
# Constructor
|
13
17
|
#
|
14
18
|
# @param [Object] msg The msg to be sent
|
@@ -26,7 +30,7 @@ module RServiceBus2
|
|
26
30
|
@correlation_id = correlation_id
|
27
31
|
@return_address = return_address
|
28
32
|
|
29
|
-
@createdat =
|
33
|
+
@createdat = Time.now
|
30
34
|
|
31
35
|
@msg_id = UUIDTools::UUID.random_create
|
32
36
|
@error_list = []
|
@@ -47,25 +51,11 @@ module RServiceBus2
|
|
47
51
|
@error_list << RServiceBus2::ErrorMessage.new(source_queue, error_string)
|
48
52
|
end
|
49
53
|
|
50
|
-
def set_remote_host_name(host_name)
|
51
|
-
@remote_host_name = host_name
|
52
|
-
end
|
53
|
-
|
54
|
-
def set_remote_queue_name(queue_name)
|
55
|
-
@remote_queue_name = queue_name
|
56
|
-
end
|
57
|
-
|
58
|
-
def send_at(timestamp)
|
59
|
-
@send_at = timestamp
|
60
|
-
end
|
61
|
-
|
62
54
|
# @return [Object] The msg to be sent
|
63
55
|
def msg
|
64
|
-
if @compressed == true
|
65
|
-
|
66
|
-
|
67
|
-
return YAML.load( @_msg )
|
68
|
-
end
|
56
|
+
return YAML.load(Zlib::Inflate.inflate(@_msg)) if @compressed == true
|
57
|
+
|
58
|
+
YAML.load(@_msg)
|
69
59
|
rescue ArgumentError => e
|
70
60
|
raise e if e.message.index('undefined class/module ').nil?
|
71
61
|
|
@@ -124,7 +124,7 @@ module RServiceBus2
|
|
124
124
|
|
125
125
|
unless @archivedir.nil?
|
126
126
|
basename = File.basename(file_path)
|
127
|
-
new_file_path = "#{@archivedir}/#{basename}.#{
|
127
|
+
new_file_path = "#{@archivedir}/#{basename}.#{Time.now.strftime('%Y%m%d%H%M%S%L')}.zip"
|
128
128
|
RServiceBus2.log "Writing to archive, #{new_file_path}"
|
129
129
|
|
130
130
|
Zip::ZipOutputStream.open(new_file_path) do |zos|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'beanstalk-client'
|
2
4
|
require 'rservicebus2/mq'
|
3
5
|
|
@@ -34,6 +36,7 @@ module RServiceBus2
|
|
34
36
|
abort
|
35
37
|
end
|
36
38
|
end
|
39
|
+
# rubocop:enable Metrics/AbcSize,Metrics/MethodLength
|
37
40
|
|
38
41
|
def subscribe(queuename)
|
39
42
|
@beanstalk.watch(queuename)
|
@@ -45,6 +48,7 @@ module RServiceBus2
|
|
45
48
|
@job = @beanstalk.reserve @timeout
|
46
49
|
rescue StandardError => e
|
47
50
|
raise NoMsgToProcess if e.message == 'TIMED_OUT'
|
51
|
+
|
48
52
|
raise e
|
49
53
|
end
|
50
54
|
@job.body
|
@@ -63,7 +67,7 @@ module RServiceBus2
|
|
63
67
|
if msg.length > @max_job_size
|
64
68
|
puts '***Attempting to send a msg which will not fit on queue.'
|
65
69
|
puts "***Msg size, #{msg.length}, max msg size, #{@max_job_size}."
|
66
|
-
|
70
|
+
raise JobTooBigError, "Msg size, #{msg.length}, max msg size,
|
67
71
|
#{@max_job_size}"
|
68
72
|
end
|
69
73
|
@beanstalk.use(queue_name)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rservicebus2/sendat_storage'
|
2
4
|
|
3
5
|
module RServiceBus2
|
@@ -16,9 +18,9 @@ module RServiceBus2
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def process
|
19
|
-
now =
|
20
|
-
@sendat_storage.
|
21
|
-
next if row['timestamp']
|
21
|
+
now = Time.now
|
22
|
+
@sendat_storage.all.each_with_index do |row, idx|
|
23
|
+
next if now <= row['timestamp']
|
22
24
|
|
23
25
|
@bus._send_needs_wrapping(row['msg'], row['queue_name'],
|
24
26
|
row['correlation_id'])
|
@@ -1,20 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
module RServiceBus2
|
3
4
|
# Send At Storage
|
4
5
|
class SendAtStorage
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
5
7
|
def self.get(uri)
|
6
8
|
case uri.scheme
|
7
9
|
when 'file'
|
8
10
|
require 'rservicebus2/sendat_storage/file'
|
9
|
-
|
11
|
+
SendAtStorageFile.new(uri)
|
10
12
|
when 'inmem'
|
11
13
|
require 'rservicebus2/sendat_storage/inmemory'
|
12
|
-
|
14
|
+
SendAtStorageInMemory.new(uri)
|
13
15
|
else
|
14
16
|
abort("Scheme, #{uri.scheme}, not recognised when configuring
|
15
17
|
SendAtStorage, #{uri}")
|
16
18
|
end
|
17
19
|
end
|
18
|
-
|
20
|
+
# rubocop:enable Metrics/MethodLength
|
19
21
|
end
|
20
22
|
end
|
@@ -1,8 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RServiceBus2
|
2
4
|
# Send at storage file
|
3
5
|
class SendAtStorageFile
|
4
6
|
def initialize(uri)
|
7
|
+
RServiceBus2.log "SendAtStorageFile configured: #{uri.path}"
|
5
8
|
@list = load(uri.path)
|
9
|
+
puts "@list: #{@list.class.name}"
|
10
|
+
@path = uri.path
|
6
11
|
end
|
7
12
|
|
8
13
|
def load(path)
|
@@ -20,7 +25,7 @@ module RServiceBus2
|
|
20
25
|
save
|
21
26
|
end
|
22
27
|
|
23
|
-
def
|
28
|
+
def all
|
24
29
|
@list
|
25
30
|
end
|
26
31
|
|
@@ -31,7 +36,7 @@ module RServiceBus2
|
|
31
36
|
|
32
37
|
def save
|
33
38
|
content = YAML.dump(@list)
|
34
|
-
File.open(@
|
39
|
+
File.open(@path, 'w') { |f| f.write(content) }
|
35
40
|
end
|
36
41
|
end
|
37
42
|
end
|