-
Notifications
You must be signed in to change notification settings - Fork 28
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
Allow configuration of IdleQueueRetentionPeriodSeconds on temporary queue client #42
Conversation
Glad to see this code check in. We are using this library for our non production set up and saw high amounts of the sqs throttling exception. Wish to use this commit soon! Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on! A couple of things to fix, and I still want to block all PRs until we address #41.
.withQueueRetentionPeriodSeconds("500"); | ||
client = AmazonSQSTemporaryQueuesClient.make(requesterBuilder); | ||
|
||
Assert.fail("Shouldn't be able to create a temporary queue with QueueRetentionPeriodSeconds not between 1 and 300 seconds"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we upgrade to JUnit 5 and use assertThrows
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added assertThrows, will create a separate issue to upgrade all tests to junit5.
@@ -16,6 +16,7 @@ | |||
|
|||
private int idleQueueSweepingPeriod = 5; | |||
private TimeUnit idleQueueSweepingTimeUnit = TimeUnit.MINUTES; | |||
private String queueRetentionPeriodSeconds = AmazonSQSTemporaryQueuesClientBuilder.QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should definitely be a Long everywhere instead. It was only a String before because it was hard-coded and only every used as a queue attribute, but now we should only be converting to and from strings in the code that reads and writes that queue attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the change to long
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the additional test coverage! :)
} | ||
|
||
@Test | ||
public void createQueueWithUnsupportedAttributes() { | ||
try { | ||
Assertions.assertThrows(IllegalArgumentException.class, () -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for applying assertThrows here :)
AmazonSQSRequesterClientBuilder requesterBuilder; | ||
if (idleQueueRetentionPeriod != null) { | ||
requesterBuilder = | ||
AmazonSQSRequesterClientBuilder.standard() | ||
.withAmazonSQS(sqs) | ||
.withInternalQueuePrefix(queueNamePrefix) | ||
.withQueueRetentionPeriodSeconds(idleQueueRetentionPeriod); | ||
} else { | ||
requesterBuilder = | ||
AmazonSQSRequesterClientBuilder.standard() | ||
.withAmazonSQS(sqs) | ||
.withInternalQueuePrefix(queueNamePrefix); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AmazonSQSRequesterClientBuilder requesterBuilder; | |
if (idleQueueRetentionPeriod != null) { | |
requesterBuilder = | |
AmazonSQSRequesterClientBuilder.standard() | |
.withAmazonSQS(sqs) | |
.withInternalQueuePrefix(queueNamePrefix) | |
.withQueueRetentionPeriodSeconds(idleQueueRetentionPeriod); | |
} else { | |
requesterBuilder = | |
AmazonSQSRequesterClientBuilder.standard() | |
.withAmazonSQS(sqs) | |
.withInternalQueuePrefix(queueNamePrefix); | |
} | |
AmazonSQSRequesterClientBuilder requesterBuilder = | |
AmazonSQSRequesterClientBuilder.standard() | |
.withAmazonSQS(sqs) | |
.withInternalQueuePrefix(queueNamePrefix); | |
if (idleQueueRetentionPeriod != null) { | |
requesterBuilder = requesterBuilder.withQueueRetentionPeriodSeconds(idleQueueRetentionPeriod); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated setup function
client = AmazonSQSTemporaryQueuesClient.make(requesterBuilder); | ||
} | ||
|
||
private void createQueue(Long idleQueueRetentionPeriod) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Consider renaming this to something more descriptive, since its not just a helper creating a queue for further testing, but actually doing the important assertions itself. Perhaps createQueueShouldSetRetentionPeriod
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the function
@@ -17,6 +17,7 @@ | |||
private int idleQueueSweepingPeriod = 5; | |||
private long queueHeartbeatInterval = AmazonSQSIdleQueueDeletingClient.HEARTBEAT_INTERVAL_SECONDS_DEFAULT; | |||
private TimeUnit idleQueueSweepingTimeUnit = TimeUnit.MINUTES; | |||
private long queueRetentionPeriodSeconds = AmazonSQSTemporaryQueuesClientBuilder.QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for not spotting this earlier, but this should really be idleQueueRetentionPeriodSeconds in all these new places. The distinction has caused confusion for customers in the past. You can't change the existing public constants, but at least new references can be more precise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated queueRetentionPeriodSeconds to idleQueueRetentionPeriodSeconds in all the new places
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@@ -5,6 +5,8 @@ | |||
|
|||
public class AmazonSQSTemporaryQueuesClientBuilder { | |||
|
|||
public final static long QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT = 300; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public final static long QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT = 300; | |
public final static long IDLE_QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT = 300; |
(and the references too of course :))
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Issue #38
Description of changes:
Allow configuration of IdleQueueRetentionPeriodSeconds on temporary queue client
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.