aws-sdk-sqs 1.63.0 → 1.64.0

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: 771f111abb0e80c50cdd2604ffccc623e3b857f71397e148cf39c86a6f4b3b01
4
- data.tar.gz: d1de38807484a6e474286728326789343c99d96a4e9f691d6e1c95d7f41c4fd1
3
+ metadata.gz: 68eb8fe977b86cb00d0fc688ebc168d08cff78fdf9a332304fcbc825c7d381cb
4
+ data.tar.gz: 88fe34be85f87be90ff063d796ec49a42098e8882b43cefede85feeb324ef5a4
5
5
  SHA512:
6
- metadata.gz: 77abf6cf9210bbbd454e584381e1f1c64e60c03b15de297f9a76808cab68485454cdb750984510c4c2e5c58632766b951852916c97f1ad5dad487f1de2e8f2ed
7
- data.tar.gz: d226ea4308c28634f4a09b1d5ecf4eac09cb4beaa4c3567269c026c2ba9430af36414261b551aadfcfda4b5723ad86f89329750756b674c28da74821ab90c14b
6
+ metadata.gz: '02289264a550230e36c1c9d0cb73a532ca0a2fc5c6ff550fb6390dd7d21c99f77f042fc99153605deaad2a7c945a8b963af34c5dfcf0e96357f83eeea79ba3c1'
7
+ data.tar.gz: 976aee45c5cb6a9db8d884e4f8abb44807aca6b6c567b3815565864a24e7e775ee32bc3fa23a052a8b8ca378cf7266e79ea0d6539ab32f97ede21f4aa1ad6b71
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 1.64.0 (2023-10-02)
5
+ ------------------
6
+
7
+ * Feature - Update QueuePoller to handle duplicate messages before yielding. Fixes bug in (#2913).
8
+
4
9
  1.63.0 (2023-09-27)
5
10
  ------------------
6
11
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.63.0
1
+ 1.64.0
@@ -2786,7 +2786,7 @@ module Aws::SQS
2786
2786
  params: params,
2787
2787
  config: config)
2788
2788
  context[:gem_name] = 'aws-sdk-sqs'
2789
- context[:gem_version] = '1.63.0'
2789
+ context[:gem_version] = '1.64.0'
2790
2790
  Seahorse::Client::Request.new(handlers, context)
2791
2791
  end
2792
2792
 
@@ -4,7 +4,6 @@ require 'set'
4
4
 
5
5
  module Aws
6
6
  module SQS
7
-
8
7
  # A utility class for long polling messages in a loop. **Messages are
9
8
  # automatically deleted from the queue at the end of the given block.**
10
9
  #
@@ -203,7 +202,6 @@ module Aws
203
202
  # ```
204
203
  #
205
204
  class QueuePoller
206
-
207
205
  # @param [String] queue_url
208
206
  # @option options [Client] :client
209
207
  # @option (see #poll)
@@ -333,7 +331,7 @@ module Aws
333
331
  loop do
334
332
  messages = get_messages(config, stats)
335
333
  if messages.empty?
336
- check_idle_timeout(config, stats, messages)
334
+ check_idle_timeout(config, stats)
337
335
  else
338
336
  process_messages(config, stats, messages, &block)
339
337
  end
@@ -348,21 +346,21 @@ module Aws
348
346
  # `#receipt_handle`.
349
347
  # @param [Integer] seconds
350
348
  def change_message_visibility_timeout(message, seconds)
351
- @client.change_message_visibility({
349
+ @client.change_message_visibility(
352
350
  queue_url: @queue_url,
353
351
  receipt_handle: message.receipt_handle,
354
- visibility_timeout: seconds,
355
- })
352
+ visibility_timeout: seconds
353
+ )
356
354
  end
357
355
 
358
356
  # @note This method should be called from inside a {#poll} block.
359
357
  # @param [#receipt_handle] message An object that responds to
360
358
  # `#receipt_handle`.
361
359
  def delete_message(message)
362
- @client.delete_message({
360
+ @client.delete_message(
363
361
  queue_url: @queue_url,
364
- receipt_handle: message.receipt_handle,
365
- })
362
+ receipt_handle: message.receipt_handle
363
+ )
366
364
  end
367
365
 
368
366
  # @note This method should be called from inside a {#poll} block.
@@ -372,16 +370,16 @@ module Aws
372
370
  def delete_messages(messages)
373
371
  @client.delete_message_batch(
374
372
  queue_url: @queue_url,
375
- entries: messages.map { |msg|
373
+ entries: messages.map do |msg|
376
374
  { id: msg.message_id, receipt_handle: msg.receipt_handle }
377
- }
375
+ end
378
376
  )
379
377
  end
380
378
 
381
379
  private
382
380
 
383
381
  def get_messages(config, stats)
384
- config.before_request.call(stats) if config.before_request
382
+ config.before_request&.call(stats)
385
383
  messages = send_request(config).messages
386
384
  stats.request_count += 1
387
385
  messages
@@ -392,17 +390,22 @@ module Aws
392
390
  @client.receive_message(params)
393
391
  end
394
392
 
395
- def check_idle_timeout(config, stats, messages)
396
- if config.idle_timeout
397
- since = stats.last_message_received_at || stats.polling_started_at
398
- idle_time = Time.now - since
399
- throw :stop_polling if idle_time > config.idle_timeout
400
- end
393
+ def check_idle_timeout(config, stats)
394
+ return unless config.idle_timeout
395
+
396
+ since = stats.last_message_received_at || stats.polling_started_at
397
+ idle_time = Time.now - since
398
+ throw :stop_polling if idle_time > config.idle_timeout
401
399
  end
402
400
 
403
401
  def process_messages(config, stats, messages, &block)
404
402
  stats.received_message_count += messages.count
405
403
  stats.last_message_received_at = Time.now
404
+
405
+ # duplicated messages will have a different receipt handle
406
+ # so we need to provide the most recent receipt to
407
+ # delete a batch - thus, filtering below by message_id
408
+ messages = messages.reverse.uniq(&:message_id).reverse!
406
409
  catch(:skip_delete) do
407
410
  yield_messages(config, messages, stats, &block)
408
411
  delete_messages(messages) unless config.skip_delete
@@ -421,7 +424,6 @@ module Aws
421
424
 
422
425
  # Statistics tracked client-side by the {QueuePoller}.
423
426
  class PollerStats
424
-
425
427
  def initialize
426
428
  @request_count = 0
427
429
  @received_message_count = 0
@@ -444,27 +446,25 @@ module Aws
444
446
 
445
447
  # @return [Time,nil]
446
448
  attr_accessor :polling_stopped_at
447
-
448
449
  end
449
450
 
450
451
  # A read-only set of configuration used by the QueuePoller.
451
452
  class PollerConfig
452
-
453
453
  # @api private
454
- CONFIG_OPTIONS = Set.new([
455
- :idle_timeout,
456
- :skip_delete,
457
- :before_request,
458
- ])
454
+ CONFIG_OPTIONS = Set.new %i[
455
+ idle_timeout
456
+ skip_delete
457
+ before_request
458
+ ]
459
459
 
460
460
  # @api private
461
- PARAM_OPTIONS = Set.new([
462
- :wait_time_seconds,
463
- :max_number_of_messages,
464
- :visibility_timeout,
465
- :attribute_names,
466
- :message_attribute_names,
467
- ])
461
+ PARAM_OPTIONS = Set.new %i[
462
+ wait_time_seconds
463
+ max_number_of_messages
464
+ visibility_timeout
465
+ attribute_names
466
+ message_attribute_names
467
+ ]
468
468
 
469
469
  # @return [Integer,nil]
470
470
  attr_reader :idle_timeout
@@ -487,7 +487,7 @@ module Aws
487
487
  max_number_of_messages: 1,
488
488
  visibility_timeout: nil,
489
489
  attribute_names: ['All'],
490
- message_attribute_names: ['All'],
490
+ message_attribute_names: ['All']
491
491
  }
492
492
  options.each do |opt_name, value|
493
493
  if CONFIG_OPTIONS.include?(opt_name)
@@ -522,7 +522,6 @@ module Aws
522
522
  PARAM_OPTIONS.each { |key| hash[key] = @request_params[key] }
523
523
  hash
524
524
  end
525
-
526
525
  end
527
526
  end
528
527
  end
data/lib/aws-sdk-sqs.rb CHANGED
@@ -54,6 +54,6 @@ require_relative 'aws-sdk-sqs/customizations'
54
54
  # @!group service
55
55
  module Aws::SQS
56
56
 
57
- GEM_VERSION = '1.63.0'
57
+ GEM_VERSION = '1.64.0'
58
58
 
59
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-sqs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.63.0
4
+ version: 1.64.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-27 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core