Skip to content

Commit 843043d

Browse files
authoredSep 17, 2021
Avoid tagging queues in CreateQueueRequest and do it afterwards to avoid QueueNameExistsException (#70)
1 parent 898366c commit 843043d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎src/main/java/com/amazonaws/services/sqs/AmazonSQSIdleQueueDeletingClient.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.function.Consumer;
1111

1212
import com.amazonaws.services.sqs.model.QueueNameExistsException;
13+
import com.amazonaws.services.sqs.model.TagQueueRequest;
1314
import com.amazonaws.services.sqs.util.Constants;
1415
import org.apache.commons.logging.Log;
1516
import org.apache.commons.logging.LogFactory;
@@ -185,13 +186,16 @@ public CreateQueueResult createQueue(CreateQueueRequest request) {
185186
long currentTimestamp = System.currentTimeMillis();
186187
CreateQueueRequest superRequest = request.clone()
187188
.withQueueName(queueName)
188-
.withAttributes(attributes)
189-
.addTagsEntry(IDLE_QUEUE_RETENTION_PERIOD_TAG, retentionPeriodString)
190-
.addTagsEntry(LAST_HEARTBEAT_TIMESTAMP_TAG, String.valueOf(currentTimestamp));
189+
.withAttributes(attributes);
191190

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

194+
TagQueueRequest tagQueueRequest = new TagQueueRequest().withQueueUrl(queueUrl)
195+
.addTagsEntry(IDLE_QUEUE_RETENTION_PERIOD_TAG, retentionPeriodString)
196+
.addTagsEntry(LAST_HEARTBEAT_TIMESTAMP_TAG, String.valueOf(currentTimestamp));
197+
amazonSqsToBeExtended.tagQueue(tagQueueRequest);
198+
195199
// TODO-RS: Filter more carefully to all attributes valid for createQueue
196200
List<String> attributeNames = Arrays.asList(QueueAttributeName.ReceiveMessageWaitTimeSeconds.toString(),
197201
QueueAttributeName.VisibilityTimeout.toString());

0 commit comments

Comments
 (0)
Please sign in to comment.