Skip to content

Commit

Permalink
Avoid tagging queues in CreateQueueRequest and do it afterwards to av…
Browse files Browse the repository at this point in the history
…oid QueueNameExistsException (#70)
  • Loading branch information
adam-aws authored Sep 17, 2021
1 parent 898366c commit 843043d
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.function.Consumer;

import com.amazonaws.services.sqs.model.QueueNameExistsException;
import com.amazonaws.services.sqs.model.TagQueueRequest;
import com.amazonaws.services.sqs.util.Constants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -185,13 +186,16 @@ public CreateQueueResult createQueue(CreateQueueRequest request) {
long currentTimestamp = System.currentTimeMillis();
CreateQueueRequest superRequest = request.clone()
.withQueueName(queueName)
.withAttributes(attributes)
.addTagsEntry(IDLE_QUEUE_RETENTION_PERIOD_TAG, retentionPeriodString)
.addTagsEntry(LAST_HEARTBEAT_TIMESTAMP_TAG, String.valueOf(currentTimestamp));
.withAttributes(attributes);

CreateQueueResult result = super.createQueue(superRequest);
String queueUrl = result.getQueueUrl();

TagQueueRequest tagQueueRequest = new TagQueueRequest().withQueueUrl(queueUrl)
.addTagsEntry(IDLE_QUEUE_RETENTION_PERIOD_TAG, retentionPeriodString)
.addTagsEntry(LAST_HEARTBEAT_TIMESTAMP_TAG, String.valueOf(currentTimestamp));
amazonSqsToBeExtended.tagQueue(tagQueueRequest);

// TODO-RS: Filter more carefully to all attributes valid for createQueue
List<String> attributeNames = Arrays.asList(QueueAttributeName.ReceiveMessageWaitTimeSeconds.toString(),
QueueAttributeName.VisibilityTimeout.toString());
Expand Down

0 comments on commit 843043d

Please sign in to comment.