message-driver 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 1337b90514d41c7c6706f472dd0d4d809a9b9d2c87398718b5648d5e11cc0cca
4
- data.tar.gz: 00c838ad1a5785b711c6253a69ecdf407c92b5aecd76b41cdce0618d48709bfc
2
+ SHA1:
3
+ metadata.gz: e9dc548fdfd73e6d0b82f2ca05a5560ef883c2bb
4
+ data.tar.gz: a55216b3b977be05bcd575e296654ab2bb75b5f0
5
5
  SHA512:
6
- metadata.gz: 0a022e82819601477f85a4fe69cfae307da7a276aac011a865c245a8a35d76947bf5822be2436185920db810ee65e36f38635b4a7c5e1738d55d2cda470f91f7
7
- data.tar.gz: 8c26175b1b69e2e7e1fbfb5380105dc2c83ef07957517eb6ba344f49efe379c1615d4d5f2b2e1dc37750a799913a042e02a8c4d87f4af19b182c5985bb533420
6
+ metadata.gz: dfa2114ec8b59a6a4fd40e72114cdace5a50367beef49de9f7531a202e2ff62cbb7049381e264ae6e743716456f5ce0a96ecaa2cb02acb6c658d67fe3fc85387
7
+ data.tar.gz: 3e37a3937bd46591458c8bd9c755625f941803e5b9caf3d1b11a9ed854c2d09a3a95ae655c52b69a827e17e617b2ec121129e3f20e17615a7cc8a61da03e145f
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.1 - 2018-06-06
4
+
5
+ * Fix an edge case with publisher acknowledgements in the bunny adapter. #40
6
+
3
7
  ## 1.0.0 - 2018-05-07
4
8
 
5
9
  We decided to go 1.0 just because it was time to be done with the 0.x since we have been using this in production since 2013.
@@ -341,7 +341,7 @@ module MessageDriver
341
341
  end
342
342
  begin
343
343
  if @in_confirms_transaction
344
- @channel.wait_for_confirms unless @rollback_only || @channel.nil?
344
+ @channel.wait_for_confirms unless @rollback_only || @channel.nil? || !@channel.using_publisher_confirms?
345
345
  elsif is_transactional? && valid? && !@need_channel_reset && @require_commit
346
346
  handle_errors do
347
347
  if @rollback_only
@@ -1,4 +1,4 @@
1
1
  module MessageDriver
2
2
  # @return [String] version of the library
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.0.1'.freeze
4
4
  end
@@ -380,6 +380,82 @@ module MessageDriver
380
380
  end
381
381
  end
382
382
 
383
+ context 'publisher confirmations in a consumer', :aggregate_failures do
384
+ let(:source_queue) { adapter_context.create_destination('subscriptions_example_queue') }
385
+ let(:destination) { adapter_context.create_destination('confirms_destination_queue') }
386
+ let(:body) { 'Testing the QueueDestination' }
387
+ let(:headers) { { 'foo' => 'bar' } }
388
+ let(:properties) { { persistent: false } }
389
+ let(:error_handler) { double('error_handler', call: nil) }
390
+
391
+ let(:subscription) { adapter_context.subscribe(source_queue, {ack: :auto, error_handler: error_handler}, &consumer) }
392
+ let(:subscription_channel) { subscription.sub_ctx.channel }
393
+
394
+ before do
395
+ allow(error_handler).to receive(:call) do |err, _msg|
396
+ puts err.inspect
397
+ end
398
+ destination.purge
399
+ source_queue.purge
400
+ subscription
401
+ allow(subscription_channel).to receive(:wait_for_confirms).and_call_original
402
+ end
403
+
404
+ after do
405
+ subscription.unsubscribe
406
+ end
407
+
408
+ context 'when messages are sent during the transaction' do
409
+ let(:consumer) do
410
+ ->(msg) do
411
+ MessageDriver::Client.with_message_transaction(type: :confirm_and_wait) do
412
+ destination.publish(msg.body, msg.headers, msg.properties)
413
+ end
414
+ end
415
+ end
416
+
417
+ it 'publishes and waits for confirmation before "committing" the transaction' do
418
+ expect {
419
+ source_queue.publish(body, headers, properties)
420
+ pause_if_needed
421
+ }.to change { destination.message_count }.from(0).to(1)
422
+
423
+ expect(subscription_channel).to be_using_publisher_confirms
424
+ expect(subscription_channel.unconfirmed_set).to be_empty
425
+
426
+ expect(adapter_context.channel).not_to be_using_publisher_confirms
427
+ expect(adapter_context.channel.unconfirmed_set).to be_nil
428
+
429
+ expect(error_handler).not_to have_received(:call)
430
+ expect(subscription_channel).to have_received(:wait_for_confirms)
431
+ end
432
+ end
433
+
434
+ context 'when no messages are sent during the transaction' do
435
+ let(:consumer) do
436
+ ->(msg) do
437
+ MessageDriver::Client.with_message_transaction(type: :confirm_and_wait) do
438
+ # do nothing
439
+ end
440
+ end
441
+ end
442
+
443
+ it 'publishes and waits for confirmation before "committing" the transaction' do
444
+ source_queue.publish(body, headers, properties)
445
+ pause_if_needed
446
+
447
+ expect(subscription.sub_ctx.channel).not_to be_using_publisher_confirms
448
+ expect(subscription.sub_ctx.channel.unconfirmed_set).to be_nil
449
+
450
+ expect(adapter_context.channel).not_to be_using_publisher_confirms
451
+ expect(adapter_context.channel.unconfirmed_set).to be_nil
452
+
453
+ expect(error_handler).not_to have_received(:call)
454
+ expect(subscription_channel).not_to have_received(:wait_for_confirms)
455
+ end
456
+ end
457
+ end
458
+
383
459
  context 'during a transaction with a transactional context' do
384
460
  let(:channel) { adapter_context.ensure_channel }
385
461
  let(:destination) { MessageDriver::Client.dynamic_destination('tx.test.queue') }
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: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Campbell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-07 00:00:00.000000000 Z
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  requirements: []
210
210
  rubyforge_project:
211
- rubygems_version: 2.7.6
211
+ rubygems_version: 2.6.14
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Easy message queues for ruby