diff --git a/lib/ex_aws_configurator/queue.ex b/lib/ex_aws_configurator/queue.ex index cbf7441..56f6746 100644 --- a/lib/ex_aws_configurator/queue.ex +++ b/lib/ex_aws_configurator/queue.ex @@ -1,7 +1,8 @@ defmodule ExAwsConfigurator.QueueAttributes do @type t :: ExAws.SQS.queue_attributes() - defstruct delay_seconds: 0, + defstruct content_based_deduplication: false, + delay_seconds: 0, fifo_queue: false, maximum_message_size: 262_144, message_retention_period: 1_209_600, diff --git a/lib/ex_aws_configurator/sqs.ex b/lib/ex_aws_configurator/sqs.ex index 674def5..dfcbbc0 100644 --- a/lib/ex_aws_configurator/sqs.ex +++ b/lib/ex_aws_configurator/sqs.ex @@ -64,6 +64,9 @@ defmodule ExAwsConfigurator.SQS do Logger.info(~s""" \n\n Creating queue #{full_name} on #{queue.region} Attributes: + #{IO.ANSI.green()}>#{IO.ANSI.reset()} content_based_deduplication: #{ + queue.attributes.content_based_deduplication + } #{IO.ANSI.green()}>#{IO.ANSI.reset()} delay_seconds: #{queue.attributes.delay_seconds} #{IO.ANSI.green()}>#{IO.ANSI.reset()} fifo_queue: #{queue.attributes.fifo_queue} #{IO.ANSI.green()}>#{IO.ANSI.reset()} maximum_message_size: #{ @@ -169,7 +172,15 @@ defmodule ExAwsConfigurator.SQS do full_name = Queue.full_name(queue) <> options.dead_letter_queue_suffix dead_letter_queue = - struct(queue, %{attributes: struct(attributes, %{redrive_policy: nil, policy: nil})}) + struct(queue, %{ + attributes: + struct(attributes, %{ + content_based_deduplication: attributes.content_based_deduplication, + fifo_queue: attributes.fifo_queue, + redrive_policy: nil, + policy: nil + }) + }) create_queue_on_sqs(full_name, dead_letter_queue, tags) diff --git a/test/ex_aws_configurator/sqs_test.exs b/test/ex_aws_configurator/sqs_test.exs index f68a63c..2485101 100644 --- a/test/ex_aws_configurator/sqs_test.exs +++ b/test/ex_aws_configurator/sqs_test.exs @@ -12,7 +12,10 @@ defmodule ExAwsConfigurator.SQSTest do add_queue_to_config(%{queue_min_config: %{}}) add_topic_to_config(build(:topic_config, name: :topic_name)) add_queue_to_config(build(:queue_config, name: :raw_queue, raw_message_delivery: true)) - add_queue_to_config(build(:queue_config, name: :fifo_queue, fifo_queue: true)) + + add_queue_to_config( + build(:queue_config, name: :fifo_queue, content_based_deduplication: true, fifo_queue: true) + ) add_queue_to_config( build(:queue_config, name: :without_failures_queue, dead_letter_queue: false) @@ -42,7 +45,9 @@ defmodule ExAwsConfigurator.SQSTest do test "create a fifo queue" do assert {:ok, %{status_code: 200}} = SQS.create_queue(:fifo_queue) - assert %{attributes: %{fifo_queue: true}} = ExAwsConfigurator.get_queue(:fifo_queue) + + assert %{attributes: %{content_based_deduplication: true, fifo_queue: true}} = + ExAwsConfigurator.get_queue(:fifo_queue) end test "raise when tries to create a queue without configuration" do diff --git a/test/support/config_factory.ex b/test/support/config_factory.ex index c3d816e..8fdfb13 100644 --- a/test/support/config_factory.ex +++ b/test/support/config_factory.ex @@ -16,6 +16,7 @@ defmodule ExAwsConfigurator.Factory.Config do raw_message_delivery = Map.get(attrs, :raw_message_delivery, false) dead_letter_queue = Map.get(attrs, :dead_letter_queue, true) fifo_queue = Map.get(attrs, :fifo_queue, false) + content_based_deduplication = Map.get(attrs, :content_based_deduplication, false) queue_config = %{ @@ -27,6 +28,7 @@ defmodule ExAwsConfigurator.Factory.Config do dead_letter_queue: dead_letter_queue ], attributes: [ + content_based_deduplication: content_based_deduplication, fifo_queue: fifo_queue ], topics: []