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

Better support for FIFO queues #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 5 additions & 6 deletions src/phoenix_letter/common/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ def parse_arguments(args):
default=10,
type=int,
choices=range(1, 11),
help="Max number of messages to received from the source queue per request (this will be pass "
"in the MaxNumberOfMessages param). Default: 10 (AWS API max limit)",
help="Max number of messages to received from the source queue per request "
"(this will be pass in the MaxNumberOfMessages param). Default: 10 "
"(AWS API max limit)",
metavar="N",
)

Expand All @@ -74,15 +75,13 @@ def parse_arguments(args):
parser.add_argument(
"--group-id",
dest="fifo_group_id",
help="Value for the MessageGroupId (used in FIFO queues). Required if '--fifo' argument is passed. Default: NULL. ",
help="Override the MessageGroupId (used in FIFO queues). "
"Only used if '--fifo' argument is passed. Default: NULL.",
type=str,
default=None,
metavar="MESSAGE_GROUP_ID",
)

parsed_args = parser.parse_args(args)

if parsed_args.is_fifo is True and parsed_args.fifo_group_id is None:
parser.error("--fifo requires the argument --group-id.")

return parsed_args
10 changes: 9 additions & 1 deletion src/phoenix_letter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ def main(args=None):
message_params["MessageAttributes"] = message["MessageAttributes"]

if args.is_fifo:
message_params["MessageGroupId"] = args.fifo_group_id
attributes = message.get("Attributes", {})
message_group_id = args.fifo_group_id
if message_group_id is None:
message_group_id = attributes.get("MessageGroupId")

message_params["MessageGroupId"] = message_group_id

if attributes.get("MessageDeduplicationId"):
message_params["MessageDeduplicationId"] = attributes.get("MessageDeduplicationId")

sqs_client.send_message(**message_params)

Expand Down