msgr 0.11.0.rc1 → 0.11.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/msgr/connection.rb +5 -0
- data/lib/msgr/dispatcher.rb +2 -0
- data/lib/msgr/message.rb +13 -1
- data/lib/msgr/version.rb +1 -1
- data/spec/integration/msgr/dispatcher_spec.rb +3 -3
- data/spec/msgr/msgr_spec.rb +26 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1702792de09a7bdb79ac0cc05e7cdc89e00ed8ed
|
4
|
+
data.tar.gz: 138ef85e022e7346efc4e2960002c0b2f8bc3a62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3683e6cdcf37754eb553ceaa6db9c40c0837dd48b2702a619a6639a76a4ecc72d6f044bfa2c8cf26e856d1a47d55aa1471bd8896390fdcf9930ddf1358de4c29
|
7
|
+
data.tar.gz: fc5e451ecd1b6f983ea41f5b6ba06970186183f5efc178e17a071edb50f7346059f80c73d660e5eacd8edfb9e0af206b9b192b659eed26c5ae96b11aff815cf9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.11.rc2
|
4
|
+
|
5
|
+
* Add nack for messages when an error is rescued by dispatcher
|
6
|
+
|
7
|
+
## 0.11.rc1
|
8
|
+
|
9
|
+
* Add pool_class config to override pool classes used by dispatcher
|
10
|
+
|
11
|
+
## 0.4 - 0.10
|
12
|
+
|
13
|
+
* Some lost history due to several crises
|
14
|
+
|
3
15
|
## 0.4.1
|
4
16
|
|
5
17
|
* Fix bug with empty routes on client start
|
data/lib/msgr/connection.rb
CHANGED
@@ -103,6 +103,11 @@ module Msgr
|
|
103
103
|
log(:debug) { "Acked message: #{delivery_tag}" }
|
104
104
|
end
|
105
105
|
|
106
|
+
def nack(delivery_tag)
|
107
|
+
channel.nack delivery_tag, false, true
|
108
|
+
log(:debug) { "Nacked message: #{delivery_tag}" }
|
109
|
+
end
|
110
|
+
|
106
111
|
def reject(delivery_tag, requeue = true)
|
107
112
|
channel.reject delivery_tag, requeue
|
108
113
|
log(:debug) { "Rejected message: #{delivery_tag}" }
|
data/lib/msgr/dispatcher.rb
CHANGED
@@ -34,6 +34,8 @@ module Msgr
|
|
34
34
|
# Acknowledge message unless it is already acknowledged.
|
35
35
|
message.ack unless message.acked?
|
36
36
|
rescue => error
|
37
|
+
message.nack unless message.acked?
|
38
|
+
|
37
39
|
log(:error) do
|
38
40
|
"Dispatcher error: #{error.class.name}: #{error}\n" +
|
39
41
|
error.backtrace.join("\n")
|
data/lib/msgr/message.rb
CHANGED
@@ -37,7 +37,19 @@ module Msgr
|
|
37
37
|
def ack
|
38
38
|
unless acked?
|
39
39
|
@acked = true
|
40
|
-
@connection.ack
|
40
|
+
@connection.ack delivery_info.delivery_tag
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Send negative message acknowledge to broker unless
|
45
|
+
# message is already acknowledged.
|
46
|
+
#
|
47
|
+
# @api public
|
48
|
+
#
|
49
|
+
def nack
|
50
|
+
unless acked?
|
51
|
+
@acked = true
|
52
|
+
@connection.nack delivery_info.delivery_tag
|
41
53
|
end
|
42
54
|
end
|
43
55
|
end
|
data/lib/msgr/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class DispatcherTestConsumer < Msgr::Consumer
|
4
4
|
def index
|
5
5
|
puts "<<< #{payload}"
|
6
6
|
end
|
@@ -8,7 +8,7 @@ end
|
|
8
8
|
|
9
9
|
describe Msgr::Dispatcher do
|
10
10
|
let(:dispatcher) { described_class.new max: 1 }
|
11
|
-
let(:consumer) { '
|
11
|
+
let(:consumer) { 'DispatcherTestConsumer' }
|
12
12
|
let(:route) do
|
13
13
|
double(:route).tap do |t|
|
14
14
|
allow(t).to receive(:consumer).and_return consumer
|
@@ -36,7 +36,7 @@ describe Msgr::Dispatcher do
|
|
36
36
|
|
37
37
|
before do
|
38
38
|
expect_any_instance_of(::Concurrent::CachedThreadPool).to receive(:post).and_return { |m, &block| block.call m}
|
39
|
-
expect_any_instance_of(
|
39
|
+
expect_any_instance_of(DispatcherTestConsumer).to receive(:index)
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should consume message' do
|
data/spec/msgr/msgr_spec.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class Receiver
|
4
|
+
end
|
5
|
+
|
6
|
+
#
|
7
|
+
class MsgrTestConsumer < Msgr::Consumer
|
4
8
|
def index
|
5
|
-
|
9
|
+
Receiver.index
|
10
|
+
end
|
11
|
+
|
12
|
+
def error
|
13
|
+
Receiver.error
|
6
14
|
end
|
7
15
|
end
|
8
16
|
|
@@ -12,11 +20,13 @@ describe Msgr do
|
|
12
20
|
Msgr.logger.level = Logger::Severity::DEBUG if Msgr.logger
|
13
21
|
end
|
14
22
|
|
15
|
-
let(:
|
23
|
+
let(:queue) { Queue.new }
|
24
|
+
let(:client) { Msgr::Client.new size: 1, prefix: SecureRandom.hex(2) }
|
16
25
|
|
17
26
|
before do
|
18
27
|
client.routes.configure do
|
19
|
-
route '
|
28
|
+
route 'test.index', to: 'msgr_test#index'
|
29
|
+
route 'test.error', to: 'msgr_test#error'
|
20
30
|
end
|
21
31
|
|
22
32
|
client.start
|
@@ -27,10 +37,19 @@ describe Msgr do
|
|
27
37
|
end
|
28
38
|
|
29
39
|
it 'should dispatch published methods to consumer' do
|
30
|
-
|
40
|
+
expect(Receiver).to receive(:index) { queue << :end }
|
41
|
+
|
42
|
+
client.publish 'Payload', to: 'test.index'
|
43
|
+
|
44
|
+
Timeout::timeout(4) { queue.pop }
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should redelivery failed messages' do
|
48
|
+
expect(Receiver).to receive(:error).ordered.and_raise RuntimeError
|
49
|
+
expect(Receiver).to receive(:error).ordered { queue << :end }
|
31
50
|
|
32
|
-
client.publish 'Payload', to: '
|
51
|
+
client.publish 'Payload', to: 'test.error'
|
33
52
|
|
34
|
-
|
53
|
+
Timeout::timeout(4) { queue.pop }
|
35
54
|
end
|
36
55
|
end
|