Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add queue URL to the error message (#79) #80

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/broadway_sqs/ex_aws_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule BroadwaySQS.ExAwsClient do
opts.queue_url
|> ExAws.SQS.receive_message(receive_messages_opts)
|> ExAws.request(opts.config)
|> wrap_received_messages(opts.ack_ref)
|> wrap_received_messages(opts)
end

@impl Acknowledger
Expand Down Expand Up @@ -62,16 +62,16 @@ defmodule BroadwaySQS.ExAwsClient do
|> ExAws.request!(ack_options.config)
end

defp wrap_received_messages({:ok, %{body: body}}, ack_ref) do
defp wrap_received_messages({:ok, %{body: body}}, %{ack_ref: ack_ref}) do
Enum.map(body.messages, fn message ->
metadata = Map.delete(message, :body)
acknowledger = build_acknowledger(message, ack_ref)
%Message{data: message.body, metadata: metadata, acknowledger: acknowledger}
end)
end

defp wrap_received_messages({:error, reason}, _) do
Logger.error("Unable to fetch events from AWS. Reason: #{inspect(reason)}")
defp wrap_received_messages({:error, reason}, %{queue_url: queue_url}) do
Logger.error("Unable to fetch events from AWS queue #{queue_url}. Reason: #{inspect(reason)}")
[]
end

Expand Down
3 changes: 2 additions & 1 deletion test/broadway_sqs/ex_aws_client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ defmodule BroadwaySQS.ExAwsClientTest do

assert capture_log(fn ->
assert ExAwsClient.receive_messages(10, opts) == []
end) =~ "[error] Unable to fetch events from AWS. Reason: \"Fake error\""
end) =~
"[error] Unable to fetch events from AWS queue my_queue. Reason: \"Fake error\""
end

test "send a SQS/ReceiveMessage request with default options", %{opts: base_opts} do
Expand Down
Loading