message-driver 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -17
- data/CHANGELOG.md +6 -1
- data/Guardfile +3 -3
- data/Rakefile +0 -2
- data/ci/reset_vhost +5 -0
- data/ci/travis_setup +10 -0
- data/features/.nav +5 -2
- data/features/CHANGELOG.md +6 -1
- data/features/amqp_specific_features/declaring_amqp_exchanges.feature +3 -3
- data/features/amqp_specific_features/nack_redelivered_messages.feature +2 -2
- data/features/amqp_specific_features/server_named_destinations.feature +3 -4
- data/features/connecting_to_multiple_brokers.feature +51 -0
- data/features/destination_metadata.feature +2 -2
- data/features/dynamic_destinations.feature +2 -2
- data/features/error_handling.feature +2 -4
- data/features/logging.feature +3 -2
- data/features/message_consumers/auto_ack_consumers.feature +4 -4
- data/features/{message_consumers.feature → message_consumers/basics.feature} +2 -2
- data/features/message_consumers/manual_ack_consumers.feature +5 -5
- data/features/message_consumers/prefetch_size.feature +4 -4
- data/features/message_consumers/transactional_ack_consumers.feature +7 -4
- data/features/rabbitmq_specific_features/dead_letter_queueing.feature +3 -3
- data/features/step_definitions/dynamic_destinations_steps.rb +2 -2
- data/features/step_definitions/logging_steps.rb +5 -1
- data/features/step_definitions/message_consumers_steps.rb +1 -1
- data/features/step_definitions/steps.rb +13 -4
- data/features/support/env.rb +1 -1
- data/features/support/test_runner.rb +6 -1
- data/lib/message_driver/adapters/base.rb +7 -1
- data/lib/message_driver/adapters/bunny_adapter.rb +22 -57
- data/lib/message_driver/adapters/in_memory_adapter.rb +3 -2
- data/lib/message_driver/adapters/stomp_adapter.rb +6 -6
- data/lib/message_driver/broker.rb +80 -19
- data/lib/message_driver/client.rb +50 -29
- data/lib/message_driver/destination.rb +2 -2
- data/lib/message_driver/errors.rb +2 -0
- data/lib/message_driver/logging.rb +7 -1
- data/lib/message_driver/message.rb +15 -4
- data/lib/message_driver/version.rb +1 -1
- data/lib/message_driver.rb +12 -5
- data/spec/integration/bunny/amqp_integration_spec.rb +15 -20
- data/spec/integration/bunny/bunny_adapter_spec.rb +13 -13
- data/spec/integration/in_memory/in_memory_adapter_spec.rb +2 -1
- data/spec/integration/stomp/stomp_adapter_spec.rb +6 -8
- data/spec/spec_helper.rb +9 -0
- data/spec/support/shared/adapter_examples.rb +6 -0
- data/spec/support/shared/context_examples.rb +2 -0
- data/spec/support/shared/destination_examples.rb +2 -0
- data/spec/units/message_driver/adapters/base_spec.rb +0 -8
- data/spec/units/message_driver/broker_spec.rb +240 -109
- data/spec/units/message_driver/client_spec.rb +69 -62
- data/spec/units/message_driver/message_spec.rb +59 -22
- data/test_lib/broker_config.rb +2 -1
- metadata +8 -7
- data/lib/bunny/session_patch.rb +0 -19
- data/spec/units/message_driver/logging_spec.rb +0 -18
@@ -6,49 +6,86 @@ module MessageDriver::Message
|
|
6
6
|
let(:body) { "The message body" }
|
7
7
|
let(:headers) { { foo: :bar, bar: :baz} }
|
8
8
|
let(:properties) { {persistent: true, client_ack: true} }
|
9
|
+
let(:ctx) { double("adapter_context") }
|
9
10
|
|
10
11
|
context "sets the body, header and properites on initialization" do
|
11
|
-
subject { described_class.new(body, headers, properties) }
|
12
|
+
subject { described_class.new(ctx, body, headers, properties) }
|
12
13
|
|
14
|
+
its(:ctx) { should be(ctx) }
|
13
15
|
its(:body) { should eq(body) }
|
14
16
|
its(:headers) { should eq(headers) }
|
15
17
|
its(:properties) { should eq(properties) }
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
|
-
|
21
|
+
let(:logger) { MessageDriver.logger }
|
22
|
+
let(:ctx) { double("adapter_context") }
|
23
|
+
let(:options) { double("options") }
|
24
|
+
subject(:message) { described_class.new(ctx, "body", {}, {}) }
|
20
25
|
|
21
26
|
describe "#ack" do
|
22
|
-
let(:options) { {foo: :bar} }
|
23
|
-
|
24
27
|
before do
|
25
|
-
|
28
|
+
allow(ctx).to receive(:ack_message)
|
26
29
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
context "when the adapter supports client acks" do
|
31
|
+
before do
|
32
|
+
allow(ctx).to receive(:supports_client_acks?) { true }
|
33
|
+
end
|
34
|
+
it "calls #ack_message with the message" do
|
35
|
+
subject.ack
|
36
|
+
expect(ctx).to have_received(:ack_message).with(subject, {})
|
37
|
+
end
|
38
|
+
it "passes the supplied options to ack_message" do
|
39
|
+
subject.ack(options)
|
40
|
+
expect(ctx).to have_received(:ack_message).with(subject, options)
|
41
|
+
end
|
30
42
|
end
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
43
|
+
context "when the adapter doesn't support client acks" do
|
44
|
+
before do
|
45
|
+
allow(ctx).to receive(:supports_client_acks?) { false }
|
46
|
+
end
|
47
|
+
it "doesn't call #ack_message" do
|
48
|
+
subject.ack
|
49
|
+
expect(ctx).not_to have_received(:ack_message)
|
50
|
+
end
|
51
|
+
it "logs a warning" do
|
52
|
+
allow(logger).to receive(:debug)
|
53
|
+
subject.ack
|
54
|
+
expect(logger).to have_received(:debug).with("this adapter does not support client acks")
|
55
|
+
end
|
35
56
|
end
|
36
57
|
end
|
37
58
|
|
38
59
|
describe "#nack" do
|
39
|
-
let(:options) { {foo: :bar} }
|
40
|
-
|
41
60
|
before do
|
42
|
-
|
61
|
+
allow(ctx).to receive(:nack_message)
|
43
62
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
63
|
+
context "when the adapter supports client nacks" do
|
64
|
+
before do
|
65
|
+
allow(ctx).to receive(:supports_client_acks?) { true }
|
66
|
+
end
|
67
|
+
it "calls #nack_message with the message" do
|
68
|
+
subject.nack
|
69
|
+
expect(ctx).to have_received(:nack_message).with(subject, {})
|
70
|
+
end
|
71
|
+
it "passes the supplied options to nack_message" do
|
72
|
+
subject.nack(options)
|
73
|
+
expect(ctx).to have_received(:nack_message).with(subject, options)
|
74
|
+
end
|
47
75
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
76
|
+
context "when the adapter doesn't support client nacks" do
|
77
|
+
before do
|
78
|
+
allow(ctx).to receive(:supports_client_acks?) { false }
|
79
|
+
end
|
80
|
+
it "doesn't call #nack_message" do
|
81
|
+
subject.nack
|
82
|
+
expect(ctx).not_to have_received(:nack_message)
|
83
|
+
end
|
84
|
+
it "logs a warning" do
|
85
|
+
allow(logger).to receive(:debug)
|
86
|
+
subject.nack
|
87
|
+
expect(logger).to have_received(:debug).with("this adapter does not support client acks")
|
88
|
+
end
|
52
89
|
end
|
53
90
|
end
|
54
91
|
end
|
data/test_lib/broker_config.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: message-driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Campbell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -83,6 +83,8 @@ files:
|
|
83
83
|
- LICENSE.txt
|
84
84
|
- README.md
|
85
85
|
- Rakefile
|
86
|
+
- ci/reset_vhost
|
87
|
+
- ci/travis_setup
|
86
88
|
- examples/basic_producer_and_consumer/Gemfile
|
87
89
|
- examples/basic_producer_and_consumer/common.rb
|
88
90
|
- examples/basic_producer_and_consumer/consumer.rb
|
@@ -98,13 +100,14 @@ files:
|
|
98
100
|
- features/amqp_specific_features/requeueing_on_nack.feature
|
99
101
|
- features/amqp_specific_features/server_named_destinations.feature
|
100
102
|
- features/client_acks.feature
|
103
|
+
- features/connecting_to_multiple_brokers.feature
|
101
104
|
- features/destination_metadata.feature
|
102
105
|
- features/dynamic_destinations.feature
|
103
106
|
- features/error_handling.feature
|
104
107
|
- features/getting_started.md
|
105
108
|
- features/logging.feature
|
106
|
-
- features/message_consumers.feature
|
107
109
|
- features/message_consumers/auto_ack_consumers.feature
|
110
|
+
- features/message_consumers/basics.feature
|
108
111
|
- features/message_consumers/manual_ack_consumers.feature
|
109
112
|
- features/message_consumers/prefetch_size.feature
|
110
113
|
- features/message_consumers/subscribe_with_a_block.feature
|
@@ -124,7 +127,6 @@ files:
|
|
124
127
|
- features/support/no_error_matcher.rb
|
125
128
|
- features/support/test_runner.rb
|
126
129
|
- features/support/transforms.rb
|
127
|
-
- lib/bunny/session_patch.rb
|
128
130
|
- lib/message-driver.rb
|
129
131
|
- lib/message_driver.rb
|
130
132
|
- lib/message_driver/adapters/base.rb
|
@@ -159,7 +161,6 @@ files:
|
|
159
161
|
- spec/units/message_driver/broker_spec.rb
|
160
162
|
- spec/units/message_driver/client_spec.rb
|
161
163
|
- spec/units/message_driver/destination_spec.rb
|
162
|
-
- spec/units/message_driver/logging_spec.rb
|
163
164
|
- spec/units/message_driver/message_spec.rb
|
164
165
|
- spec/units/message_driver/subscription_spec.rb
|
165
166
|
- test_lib/broker_config.rb
|
@@ -199,13 +200,14 @@ test_files:
|
|
199
200
|
- features/amqp_specific_features/requeueing_on_nack.feature
|
200
201
|
- features/amqp_specific_features/server_named_destinations.feature
|
201
202
|
- features/client_acks.feature
|
203
|
+
- features/connecting_to_multiple_brokers.feature
|
202
204
|
- features/destination_metadata.feature
|
203
205
|
- features/dynamic_destinations.feature
|
204
206
|
- features/error_handling.feature
|
205
207
|
- features/getting_started.md
|
206
208
|
- features/logging.feature
|
207
|
-
- features/message_consumers.feature
|
208
209
|
- features/message_consumers/auto_ack_consumers.feature
|
210
|
+
- features/message_consumers/basics.feature
|
209
211
|
- features/message_consumers/manual_ack_consumers.feature
|
210
212
|
- features/message_consumers/prefetch_size.feature
|
211
213
|
- features/message_consumers/subscribe_with_a_block.feature
|
@@ -241,6 +243,5 @@ test_files:
|
|
241
243
|
- spec/units/message_driver/broker_spec.rb
|
242
244
|
- spec/units/message_driver/client_spec.rb
|
243
245
|
- spec/units/message_driver/destination_spec.rb
|
244
|
-
- spec/units/message_driver/logging_spec.rb
|
245
246
|
- spec/units/message_driver/message_spec.rb
|
246
247
|
- spec/units/message_driver/subscription_spec.rb
|
data/lib/bunny/session_patch.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'bunny'
|
2
|
-
|
3
|
-
module Bunny
|
4
|
-
class Session
|
5
|
-
def cleanup_threads
|
6
|
-
log_errors { self.maybe_shutdown_heartbeat_sender }
|
7
|
-
log_errors { self.maybe_shutdown_reader_loop }
|
8
|
-
log_errors { self.close_transport }
|
9
|
-
end
|
10
|
-
|
11
|
-
def log_errors
|
12
|
-
begin
|
13
|
-
yield
|
14
|
-
rescue => e
|
15
|
-
@logger.info "#{e.class}: #{e.to_s}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module MessageDriver
|
4
|
-
describe Logging do
|
5
|
-
class TestLogger
|
6
|
-
include Logging
|
7
|
-
end
|
8
|
-
subject { TestLogger.new }
|
9
|
-
|
10
|
-
describe "#logger" do
|
11
|
-
let(:logger) { double(Logger) }
|
12
|
-
it "returns the broker logger" do
|
13
|
-
allow(MessageDriver::Broker).to receive(:logger).and_return(logger)
|
14
|
-
expect(subject.logger).to be logger
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|