action_subscriber 5.2.0-java → 5.2.1-java
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bca78c71253cc0e0b3c8f4c7b2ba62bc9b98919b5f66f057f14e29b6d646aba4
|
4
|
+
data.tar.gz: 38e3d342e82a51bbfc07cc6f8cf48d273723553b0946b3d00802269ad0ddb783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4beea316e1c5f47b62ee9d49a450fd47c1b166e426cbdb625d96e198e2b995d76682144857ef62b114dafea062001b6bd329598b8830950980c8d0733ed3ebc
|
7
|
+
data.tar.gz: 1f6daf1342da85dca5c9b19054c4d801cc0c94781fe36cd4a1bbdbafb13901d9b827ae18b60677a0b2528b39eca06a2b984eb38083d4f88ae83a0d77f51db076
|
@@ -30,9 +30,22 @@ module ActionSubscriber
|
|
30
30
|
::MarchHare::ThreadPools.fixed_of_size(options[:threadpool_size])
|
31
31
|
end
|
32
32
|
connection = ::MarchHare.connect(options)
|
33
|
+
connection.on_blocked do |reason|
|
34
|
+
on_blocked(reason)
|
35
|
+
end
|
36
|
+
connection.on_unblocked do
|
37
|
+
on_unblocked
|
38
|
+
end
|
39
|
+
connection
|
33
40
|
else
|
34
41
|
connection = ::Bunny.new(options)
|
35
42
|
connection.start
|
43
|
+
connection.on_blocked do |blocked_message|
|
44
|
+
on_blocked(blocked_message.reason)
|
45
|
+
end
|
46
|
+
connection.on_unblocked do
|
47
|
+
on_unblocked
|
48
|
+
end
|
36
49
|
connection
|
37
50
|
end
|
38
51
|
end
|
@@ -59,5 +72,15 @@ module ActionSubscriber
|
|
59
72
|
}
|
60
73
|
end
|
61
74
|
private_class_method :connection_options
|
75
|
+
|
76
|
+
def self.on_blocked(reason)
|
77
|
+
::ActiveSupport::Notifications.instrument("connection_blocked.action_subscriber", :reason => reason)
|
78
|
+
end
|
79
|
+
private_class_method :on_blocked
|
80
|
+
|
81
|
+
def self.on_unblocked
|
82
|
+
::ActiveSupport::Notifications.instrument("connection_unblocked.action_subscriber")
|
83
|
+
end
|
84
|
+
private_class_method :on_unblocked
|
62
85
|
end
|
63
86
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ::ActionSubscriber::RabbitConnection do
|
4
|
+
let(:reason) { "low on disk" }
|
5
|
+
|
6
|
+
before { ActionSubscriber.draw_routes {} }
|
7
|
+
|
8
|
+
context "on_block" do
|
9
|
+
if ::RUBY_PLATFORM == "java"
|
10
|
+
def trigger_mocked_blocking_event(connection, reason)
|
11
|
+
amqp_message = ::Java::ComRabbitmqClient::AMQP::Connection::Blocked::Builder.new.
|
12
|
+
reason(reason).build
|
13
|
+
amq_command = ::Java::ComRabbitmqClientImpl::AMQCommand.new(amqp_message)
|
14
|
+
|
15
|
+
connection.send(:processControlCommand, amq_command)
|
16
|
+
end
|
17
|
+
else
|
18
|
+
def trigger_mocked_blocking_event(connection, reason)
|
19
|
+
connection.send(:handle_frame, 0, ::AMQ::Protocol::Connection::Blocked.new(reason))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "can deliver an on_blocked message" do
|
24
|
+
expect(::ActiveSupport::Notifications).to receive(:instrument).
|
25
|
+
with("connection_blocked.action_subscriber", :reason => reason)
|
26
|
+
|
27
|
+
described_class.with_connection do |connection|
|
28
|
+
# NOTE: Trigger the receiving of a blocked message from the broker.
|
29
|
+
# It's a bit of a hack but it is a more realistic test without changing
|
30
|
+
# memory alarms.
|
31
|
+
trigger_mocked_blocking_event(connection, reason)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "on_unblocked" do
|
37
|
+
if ::RUBY_PLATFORM == "java"
|
38
|
+
def trigger_mocked_unblocked_event(connection, reason)
|
39
|
+
amqp_message = ::Java::ComRabbitmqClient::AMQP::Connection::Unblocked::Builder.new.
|
40
|
+
build
|
41
|
+
amq_command = ::Java::ComRabbitmqClientImpl::AMQCommand.new(amqp_message)
|
42
|
+
|
43
|
+
connection.send(:processControlCommand, amq_command)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
def trigger_mocked_unblocked_event(connection, reason)
|
47
|
+
connection.send(:handle_frame, 0, ::AMQ::Protocol::Connection::Unblocked.new)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "can deliver an on_unblocked message" do
|
52
|
+
expect(::ActiveSupport::Notifications).to receive(:instrument).
|
53
|
+
with("connection_unblocked.action_subscriber")
|
54
|
+
|
55
|
+
described_class.with_connection do |connection|
|
56
|
+
# NOTE: Trigger the receiving of an unblocked message from the broker.
|
57
|
+
# It's a bit of a hack but it is a more realistic test without changing
|
58
|
+
# memory alarms.
|
59
|
+
trigger_mocked_unblocked_event(connection, reason)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Brian Stien
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2020-05-
|
15
|
+
date: 2020-05-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,6 +273,7 @@ files:
|
|
273
273
|
- spec/lib/action_subscriber/middleware/error_handler_spec.rb
|
274
274
|
- spec/lib/action_subscriber/middleware/router_spec.rb
|
275
275
|
- spec/lib/action_subscriber/middleware/runner_spec.rb
|
276
|
+
- spec/lib/action_subscriber/rabbit_connection_spec.rb
|
276
277
|
- spec/lib/action_subscriber/router_spec.rb
|
277
278
|
- spec/lib/action_subscriber/subscribable_spec.rb
|
278
279
|
- spec/spec_helper.rb
|
@@ -324,6 +325,7 @@ test_files:
|
|
324
325
|
- spec/lib/action_subscriber/middleware/error_handler_spec.rb
|
325
326
|
- spec/lib/action_subscriber/middleware/router_spec.rb
|
326
327
|
- spec/lib/action_subscriber/middleware/runner_spec.rb
|
328
|
+
- spec/lib/action_subscriber/rabbit_connection_spec.rb
|
327
329
|
- spec/lib/action_subscriber/router_spec.rb
|
328
330
|
- spec/lib/action_subscriber/subscribable_spec.rb
|
329
331
|
- spec/spec_helper.rb
|