message-driver 0.2.0.rc1 → 0.2.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +11 -1
- data/features/CHANGELOG.md +11 -1
- data/features/amqp_specific_features/nack_redelivered_messages.feature +10 -6
- data/features/message_consumers/prefetch_size.feature +59 -0
- data/features/step_definitions/message_consumers_steps.rb +0 -5
- data/lib/message_driver/adapters/bunny_adapter.rb +35 -19
- data/lib/message_driver/adapters/stomp_adapter.rb +2 -2
- data/lib/message_driver/client.rb +14 -10
- data/lib/message_driver/version.rb +1 -1
- data/spec/integration/stomp/stomp_adapter_spec.rb +3 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f170e7f772832db44e2182d0ec0e9b57a3d7c35d
|
4
|
+
data.tar.gz: 932d64d463e45ccd9a5729aec220b334ccc304e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cf33a6bc250b26d594be85bc3ca6d78d0e9d365d3235f546d930a2fb9d9a046be02a2870a022d5ee33c57fcdcdbe57f2b605e1ec578e5028236f3dd0c512205
|
7
|
+
data.tar.gz: 836edced5bb12c61b080a475d67adfe0dc643114d83399996e4e0498984483e9b207d10dba41251ed473444abc1c547ffd38fe767fb7b534aa4099b63fa170a0
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -12,7 +12,7 @@ env:
|
|
12
12
|
- ADAPTER=bunny:0.9.0
|
13
13
|
- ADAPTER=bunny:0.10.0
|
14
14
|
- ADAPTER=stomp
|
15
|
-
- ADAPTER=bunny:1.0.0.
|
15
|
+
- ADAPTER=bunny:1.0.0.rc
|
16
16
|
rvm:
|
17
17
|
- 2.0.0
|
18
18
|
- 1.9.3
|
@@ -27,7 +27,7 @@ matrix:
|
|
27
27
|
- rvm: jruby-head
|
28
28
|
env: ADAPTER=bunny:0.9.0
|
29
29
|
allow_failures:
|
30
|
-
- env: ADAPTER=bunny:1.0.0.
|
30
|
+
- env: ADAPTER=bunny:1.0.0.rc
|
31
31
|
- rvm: jruby-head
|
32
32
|
- rvm: rbx-19mode
|
33
33
|
- rvm: jruby-19mode
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.0.rc2 - 2013-10-30
|
4
|
+
|
5
|
+
* Features
|
6
|
+
* Prefetch size for bunny consumers
|
7
|
+
* Bugs
|
8
|
+
* better error handling for transaction bunny consumers
|
9
|
+
|
3
10
|
## 0.2.0.rc1 - 2013-09-23
|
4
11
|
|
5
12
|
* Features
|
6
|
-
* Message Consumers
|
13
|
+
* Message Consumers, all different flavors
|
7
14
|
* Bunny and InMemory adapters
|
8
15
|
* Client Acks
|
9
16
|
* Bunny adapter
|
17
|
+
* Bunny adapter
|
18
|
+
* much better connection and channel error handling, including
|
19
|
+
reconnecting when broker becomes unreachable
|
10
20
|
* Adapters
|
11
21
|
* begin work on Stomp 1.1/1.2 adapter
|
12
22
|
|
data/features/CHANGELOG.md
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.0.rc2 - 2013-10-30
|
4
|
+
|
5
|
+
* Features
|
6
|
+
* Prefetch size for bunny consumers
|
7
|
+
* Bugs
|
8
|
+
* better error handling for transaction bunny consumers
|
9
|
+
|
3
10
|
## 0.2.0.rc1 - 2013-09-23
|
4
11
|
|
5
12
|
* Features
|
6
|
-
* Message Consumers
|
13
|
+
* Message Consumers, all different flavors
|
7
14
|
* Bunny and InMemory adapters
|
8
15
|
* Client Acks
|
9
16
|
* Bunny adapter
|
17
|
+
* Bunny adapter
|
18
|
+
* much better connection and channel error handling, including
|
19
|
+
reconnecting when broker becomes unreachable
|
10
20
|
* Adapters
|
11
21
|
* begin work on Stomp 1.1/1.2 adapter
|
12
22
|
|
@@ -25,7 +25,7 @@ Feature: Nacking Redelievered Messages from a consumer
|
|
25
25
|
And I have a destination :rabbit_track with no messages on it
|
26
26
|
|
27
27
|
|
28
|
-
Scenario: Raising
|
28
|
+
Scenario: Raising an error in an auto_ack consumer
|
29
29
|
Given I have a message consumer
|
30
30
|
"""ruby
|
31
31
|
MessageDriver::Broker.consumer(:manual_redeliver) do |message|
|
@@ -57,7 +57,7 @@ Feature: Nacking Redelievered Messages from a consumer
|
|
57
57
|
| Auto Retry 2 Attempt |
|
58
58
|
|
59
59
|
|
60
|
-
Scenario: Raising
|
60
|
+
Scenario: Raising an error in a transactional consumer
|
61
61
|
Given I have a message consumer
|
62
62
|
"""ruby
|
63
63
|
@attempts = 0
|
@@ -76,17 +76,21 @@ Feature: Nacking Redelievered Messages from a consumer
|
|
76
76
|
| body |
|
77
77
|
| Transactional Redeliver 1 |
|
78
78
|
| Transactional Redeliver 2 |
|
79
|
-
|
80
|
-
|
79
|
+
| Transactional Redeliver 3 |
|
80
|
+
| Transactional Redeliver 4 |
|
81
|
+
| Transactional Redeliver 5 |
|
81
82
|
And I let the subscription process
|
82
83
|
|
83
84
|
Then I expect to find no messages on :rabbit_track
|
84
85
|
Then I expect to find no messages on :rabbit_work
|
85
86
|
Then I expect the following check to pass
|
86
87
|
"""ruby
|
87
|
-
expect(@attempts).to eq(
|
88
|
+
expect(@attempts).to eq(10)
|
88
89
|
"""
|
89
|
-
Then I expect to find the following
|
90
|
+
Then I expect to find the following 5 messages on :rabbit_dlq
|
90
91
|
| body |
|
91
92
|
| Transactional Redeliver 1 |
|
92
93
|
| Transactional Redeliver 2 |
|
94
|
+
| Transactional Redeliver 3 |
|
95
|
+
| Transactional Redeliver 4 |
|
96
|
+
| Transactional Redeliver 5 |
|
@@ -0,0 +1,59 @@
|
|
1
|
+
@bunny
|
2
|
+
@wip
|
3
|
+
Feature: Message Consumers prefetch size
|
4
|
+
You can set the prefetch size for your message consumers
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am connected to the broker
|
8
|
+
And I have a destination :dest_queue_1 with no messages on it
|
9
|
+
And I have a destination :dest_queue_2 with no messages on it
|
10
|
+
And I have a destination :source_queue with no messages on it
|
11
|
+
|
12
|
+
Scenario: Consuming Messages
|
13
|
+
Given I have a message consumer
|
14
|
+
"""ruby
|
15
|
+
MessageDriver::Broker.consumer(:my_consumer_1) do |message|
|
16
|
+
MessageDriver::Client.publish(:dest_queue_1, message.body)
|
17
|
+
end
|
18
|
+
"""
|
19
|
+
And I have a message consumer
|
20
|
+
"""ruby
|
21
|
+
MessageDriver::Broker.consumer(:my_consumer_2) do |message|
|
22
|
+
MessageDriver::Client.publish(:dest_queue_2, message.body)
|
23
|
+
end
|
24
|
+
"""
|
25
|
+
And I create a subscription
|
26
|
+
"""ruby
|
27
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer_1, ack: :auto, prefetch_size: 20)
|
28
|
+
MessageDriver::Client.subscribe(:source_queue, :my_consumer_2, ack: :auto, prefetch_size: 1)
|
29
|
+
"""
|
30
|
+
|
31
|
+
When I send the following messages to :source_queue
|
32
|
+
| body |
|
33
|
+
| Auto Ack 1 |
|
34
|
+
| Auto Ack 2 |
|
35
|
+
| Auto Ack 3 |
|
36
|
+
| Auto Ack 4 |
|
37
|
+
| Auto Ack 5 |
|
38
|
+
| Auto Ack 6 |
|
39
|
+
| Auto Ack 7 |
|
40
|
+
| Auto Ack 8 |
|
41
|
+
| Auto Ack 9 |
|
42
|
+
| Auto Ack 10 |
|
43
|
+
And I let the subscription process
|
44
|
+
|
45
|
+
Then I expect to find no messages on :source_queue
|
46
|
+
And I expect to find no messages on :dest_queue_2
|
47
|
+
And I expect to find the following 2 messages on :dest_queue_1
|
48
|
+
| body |
|
49
|
+
| Auto Ack 1 |
|
50
|
+
| Auto Ack 2 |
|
51
|
+
| Auto Ack 3 |
|
52
|
+
| Auto Ack 4 |
|
53
|
+
| Auto Ack 5 |
|
54
|
+
| Auto Ack 6 |
|
55
|
+
| Auto Ack 7 |
|
56
|
+
| Auto Ack 8 |
|
57
|
+
| Auto Ack 9 |
|
58
|
+
| Auto Ack 10 |
|
59
|
+
|
@@ -118,6 +118,9 @@ module MessageDriver
|
|
118
118
|
@error_handler = options[:error_handler]
|
119
119
|
@sub_ctx.with_channel do |ch|
|
120
120
|
queue = destination.bunny_queue(@sub_ctx.channel)
|
121
|
+
if options.has_key? :prefetch_size
|
122
|
+
ch.prefetch(options[:prefetch_size])
|
123
|
+
end
|
121
124
|
ack_mode = case options[:ack]
|
122
125
|
when :auto, nil
|
123
126
|
:auto
|
@@ -145,20 +148,20 @@ module MessageDriver
|
|
145
148
|
end
|
146
149
|
end
|
147
150
|
rescue => e
|
148
|
-
if
|
149
|
-
|
150
|
-
|
151
|
+
if [:auto, :transactional].include? ack_mode
|
152
|
+
requeue = true
|
153
|
+
if e.is_a?(DontRequeue) || (options[:retry_redelivered] == false && message.redelivered?)
|
154
|
+
requeue = false
|
151
155
|
end
|
152
|
-
|
153
|
-
if @sub_ctx.valid? && ack_mode == :auto
|
156
|
+
if @sub_ctx.valid?
|
154
157
|
begin
|
155
|
-
@sub_ctx.nack_message(message, requeue:
|
158
|
+
@sub_ctx.nack_message(message, requeue: requeue)
|
156
159
|
rescue => e
|
157
160
|
logger.error exception_to_str(e)
|
158
161
|
end
|
159
162
|
end
|
160
|
-
@error_handler.call(e, message) unless @error_handler.nil?
|
161
163
|
end
|
164
|
+
@error_handler.call(e, message) unless @error_handler.nil?
|
162
165
|
end
|
163
166
|
end
|
164
167
|
end
|
@@ -257,10 +260,12 @@ module MessageDriver
|
|
257
260
|
raise MessageDriver::TransactionError, "you can't finish the transaction unless you already in one!" if !in_transaction? && !channel_commit
|
258
261
|
begin
|
259
262
|
if is_transactional? && valid? && !@need_channel_reset
|
260
|
-
|
261
|
-
@
|
262
|
-
|
263
|
-
|
263
|
+
handle_errors do
|
264
|
+
if @rollback_only
|
265
|
+
@channel.tx_rollback
|
266
|
+
else
|
267
|
+
@channel.tx_commit
|
268
|
+
end
|
264
269
|
end
|
265
270
|
end
|
266
271
|
ensure
|
@@ -341,15 +346,9 @@ module MessageDriver
|
|
341
346
|
end
|
342
347
|
end
|
343
348
|
|
344
|
-
def
|
345
|
-
raise MessageDriver::TransactionRollbackOnly if @rollback_only
|
346
|
-
raise MessageDriver::Error, "oh nos!" if !valid?
|
347
|
-
@channel = adapter.connection.create_channel if @channel.nil?
|
348
|
-
reset_channel if @need_channel_reset
|
349
|
+
def handle_errors
|
349
350
|
begin
|
350
|
-
|
351
|
-
commit_transaction(true) if require_commit && is_transactional? && !in_transaction?
|
352
|
-
result
|
351
|
+
yield
|
353
352
|
rescue Bunny::ChannelLevelException => e
|
354
353
|
@need_channel_reset = true
|
355
354
|
@rollback_only = true if in_transaction?
|
@@ -358,12 +357,29 @@ module MessageDriver
|
|
358
357
|
else
|
359
358
|
raise MessageDriver::WrappedError.new(e.to_s, e)
|
360
359
|
end
|
360
|
+
rescue Bunny::ChannelAlreadyClosed => e
|
361
|
+
@need_channel_reset = true
|
362
|
+
@rollback_only = true if in_transaction?
|
363
|
+
raise MessageDriver::WrappedError.new(e.to_s, e)
|
361
364
|
rescue *NETWORK_ERRORS => e
|
365
|
+
@need_channel_reset = true
|
362
366
|
@rollback_only = true if in_transaction?
|
363
367
|
raise MessageDriver::ConnectionError.new(e.to_s, e)
|
364
368
|
end
|
365
369
|
end
|
366
370
|
|
371
|
+
def with_channel(require_commit=true)
|
372
|
+
raise MessageDriver::TransactionRollbackOnly if @rollback_only
|
373
|
+
raise MessageDriver::Error, "oh nos!" if !valid?
|
374
|
+
@channel = adapter.connection.create_channel if @channel.nil?
|
375
|
+
reset_channel if @need_channel_reset
|
376
|
+
handle_errors do
|
377
|
+
result = yield @channel
|
378
|
+
commit_transaction(true) if require_commit && is_transactional? && !in_transaction?
|
379
|
+
result
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
367
383
|
def args_to_message(delivery_info, properties, payload)
|
368
384
|
Message.new(delivery_info, properties, payload)
|
369
385
|
end
|
@@ -116,10 +116,10 @@ module MessageDriver
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def validate_stomp_version
|
119
|
-
required = Gem::Requirement.create('~> 1.
|
119
|
+
required = Gem::Requirement.create('~> 1.3.1')
|
120
120
|
current = Gem::Version.create(Stomp::Version::STRING)
|
121
121
|
unless required.satisfied_by? current
|
122
|
-
raise MessageDriver::Error, "stomp 1.
|
122
|
+
raise MessageDriver::Error, "stomp 1.3.1 or a later version of the 1.3.x series is required for the stomp adapter"
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
@@ -47,18 +47,22 @@ module MessageDriver
|
|
47
47
|
wrapper = fetch_context_wrapper
|
48
48
|
wrapper.increment_transaction_depth
|
49
49
|
begin
|
50
|
-
if wrapper.
|
51
|
-
wrapper.
|
52
|
-
|
53
|
-
yield
|
54
|
-
wrapper.ctx.commit_transaction
|
55
|
-
rescue
|
50
|
+
if wrapper.ctx.supports_transactions?
|
51
|
+
if wrapper.transaction_depth == 1
|
52
|
+
wrapper.ctx.begin_transaction(options)
|
56
53
|
begin
|
57
|
-
|
58
|
-
rescue
|
59
|
-
|
54
|
+
yield
|
55
|
+
rescue
|
56
|
+
begin
|
57
|
+
wrapper.ctx.rollback_transaction
|
58
|
+
rescue => e
|
59
|
+
logger.error exception_to_str(e)
|
60
|
+
end
|
61
|
+
raise
|
60
62
|
end
|
61
|
-
|
63
|
+
wrapper.ctx.commit_transaction
|
64
|
+
else
|
65
|
+
yield
|
62
66
|
end
|
63
67
|
else
|
64
68
|
logger.debug("this adapter does not support transactions")
|
@@ -16,7 +16,7 @@ module MessageDriver::Adapters
|
|
16
16
|
stub_const("Stomp::Version::STRING", version)
|
17
17
|
expect {
|
18
18
|
described_class.new(connection_attrs)
|
19
|
-
}.to raise_error MessageDriver::Error, "stomp 1.
|
19
|
+
}.to raise_error MessageDriver::Error, "stomp 1.3.1 or a later version of the 1.3.x series is required for the stomp adapter"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
shared_examples "doesn't raise a stomp error" do
|
@@ -28,13 +28,13 @@ module MessageDriver::Adapters
|
|
28
28
|
}.to_not raise_error
|
29
29
|
end
|
30
30
|
end
|
31
|
-
%w(1.1.0 1.2.9 1.3.0).each do |v|
|
31
|
+
%w(1.1.0 1.2.9 1.3.0 1.4.0).each do |v|
|
32
32
|
context "stomp version #{v}" do
|
33
33
|
let(:version) { v }
|
34
34
|
include_examples "raises a stomp error"
|
35
35
|
end
|
36
36
|
end
|
37
|
-
%w(1.
|
37
|
+
%w(1.3.1 1.3.5).each do |v|
|
38
38
|
context "stomp version #{v}" do
|
39
39
|
let(:version) { v }
|
40
40
|
include_examples "doesn't raise a stomp error"
|
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.2.0.
|
4
|
+
version: 0.2.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Campbell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- features/message_consumers.feature
|
107
107
|
- features/message_consumers/auto_ack_consumers.feature
|
108
108
|
- features/message_consumers/manual_ack_consumers.feature
|
109
|
+
- features/message_consumers/prefetch_size.feature
|
109
110
|
- features/message_consumers/transactional_ack_consumers.feature
|
110
111
|
- features/publishing_a_message.feature
|
111
112
|
- features/publishing_with_transactions.feature
|
@@ -204,6 +205,7 @@ test_files:
|
|
204
205
|
- features/message_consumers.feature
|
205
206
|
- features/message_consumers/auto_ack_consumers.feature
|
206
207
|
- features/message_consumers/manual_ack_consumers.feature
|
208
|
+
- features/message_consumers/prefetch_size.feature
|
207
209
|
- features/message_consumers/transactional_ack_consumers.feature
|
208
210
|
- features/publishing_a_message.feature
|
209
211
|
- features/publishing_with_transactions.feature
|