lib/sqewer/connection.rb in sqewer-6.5.0 vs lib/sqewer/connection.rb in sqewer-6.5.1
- old
+ new
@@ -50,13 +50,13 @@
# Receive at most 10 messages from the queue, and return the array of Message objects. Retries for at
# most 900 seconds (15 minutes) and then gives up, thereby crashing the read loop. If SQS is not available
# even after 15 minutes it is either down or the server is misconfigured. Either way it makes no sense to
# continue.
#
- # @return [Array<Message>] an array of Message objects
+ # @return [Array<Message>] an array of Message objects
def receive_messages
- Retriable.retriable on: Seahorse::Client::NetworkingError, tries: MAX_RANDOM_RECEIVE_FAILURES do
+ Retriable.retriable on: network_and_aws_sdk_errors, tries: MAX_RANDOM_RECEIVE_FAILURES do
response = client.receive_message(
queue_url: @queue_url,
attribute_names: ['All'],
wait_time_seconds: DEFAULT_TIMEOUT_SECONDS,
max_number_of_messages: BATCH_RECEIVE_SIZE
@@ -67,11 +67,11 @@
# Send a message to the backing queue
#
# @param message_body[String] the message to send
# @param kwargs_for_send[Hash] additional arguments for the submit (such as `delay_seconds`).
- # Passes the arguments to the AWS SDK.
+ # Passes the arguments to the AWS SDK.
# @return [void]
def send_message(message_body, **kwargs_for_send)
send_multiple_messages {|via| via.send_message(message_body, **kwargs_for_send) }
end
@@ -189,11 +189,15 @@
buffer.each_batch {|batch| handle_batch_with_retries(:delete_message_batch, batch) }
end
private
+ def network_and_aws_sdk_errors
+ [NotOurFaultAwsError, Seahorse::Client::NetworkingError, Aws::SQS::Errors::InternalError]
+ end
+
def handle_batch_with_retries(method, batch)
- Retriable.retriable on: [NotOurFaultAwsError, Seahorse::Client::NetworkingError], tries: MAX_RANDOM_FAILURES_PER_CALL do
+ Retriable.retriable on: network_and_aws_sdk_errors, tries: MAX_RANDOM_FAILURES_PER_CALL do
resp = client.send(method, queue_url: @queue_url, entries: batch)
wrong_messages, aws_failures = resp.failed.partition {|m| m.sender_fault }
if wrong_messages.any?
err = wrong_messages.inspect + ', ' + resp.inspect
raise "#{wrong_messages.length} messages failed while doing #{method.to_s} with error: #{err}"