10
10
import java .util .function .Consumer ;
11
11
12
12
import com .amazonaws .services .sqs .model .QueueNameExistsException ;
13
+ import com .amazonaws .services .sqs .util .Constants ;
13
14
import org .apache .commons .logging .Log ;
14
15
import org .apache .commons .logging .LogFactory ;
15
16
@@ -63,12 +64,6 @@ class AmazonSQSIdleQueueDeletingClient extends AbstractAmazonSQSClientWrapper {
63
64
64
65
private static final Log LOG = LogFactory .getLog (AmazonSQSIdleQueueDeletingClient .class );
65
66
66
- // Publicly visible constants
67
- public static final String IDLE_QUEUE_RETENTION_PERIOD = "IdleQueueRetentionPeriodSeconds" ;
68
- public static final long MINIMUM_IDLE_QUEUE_RETENTION_PERIOD_SECONDS = 1 ;
69
- public static final long HEARTBEAT_INTERVAL_SECONDS_DEFAULT = 5 ;
70
- public static final long HEARTBEAT_INTERVAL_SECONDS_MIN_VALUE = 1 ;
71
-
72
67
static final String IDLE_QUEUE_RETENTION_PERIOD_TAG = "__IdleQueueRetentionPeriodSeconds" ;
73
68
74
69
private static final String SWEEPING_QUEUE_DLQ_SUFFIX = "_DLQ" ;
@@ -111,15 +106,15 @@ public AmazonSQSIdleQueueDeletingClient(AmazonSQS sqs, String queueNamePrefix, L
111
106
this .queueNamePrefix = queueNamePrefix ;
112
107
113
108
if (heartbeatIntervalSeconds != null ) {
114
- if (heartbeatIntervalSeconds < HEARTBEAT_INTERVAL_SECONDS_MIN_VALUE ) {
109
+ if (heartbeatIntervalSeconds < Constants . HEARTBEAT_INTERVAL_SECONDS_MIN_VALUE ) {
115
110
throw new IllegalArgumentException ("Heartbeat Interval Seconds: " +
116
111
heartbeatIntervalSeconds +
117
112
" must be equal to or bigger than " +
118
- HEARTBEAT_INTERVAL_SECONDS_MIN_VALUE );
113
+ Constants . HEARTBEAT_INTERVAL_SECONDS_MIN_VALUE );
119
114
}
120
115
this .heartbeatIntervalSeconds = heartbeatIntervalSeconds ;
121
116
} else {
122
- this .heartbeatIntervalSeconds = HEARTBEAT_INTERVAL_SECONDS_DEFAULT ;
117
+ this .heartbeatIntervalSeconds = Constants . HEARTBEAT_INTERVAL_SECONDS_DEFAULT ;
123
118
}
124
119
}
125
120
@@ -201,7 +196,7 @@ public CreateQueueResult createQueue(CreateQueueRequest request) {
201
196
List <String > attributeNames = Arrays .asList (QueueAttributeName .ReceiveMessageWaitTimeSeconds .toString (),
202
197
QueueAttributeName .VisibilityTimeout .toString ());
203
198
Map <String , String > createdAttributes = amazonSqsToBeExtended .getQueueAttributes (queueUrl , attributeNames ).getAttributes ();
204
- createdAttributes .put (IDLE_QUEUE_RETENTION_PERIOD , retentionPeriodString );
199
+ createdAttributes .put (Constants . IDLE_QUEUE_RETENTION_PERIOD , retentionPeriodString );
205
200
206
201
QueueMetadata metadata = new QueueMetadata (queueName , queueUrl , createdAttributes );
207
202
queues .put (queueUrl , metadata );
@@ -214,15 +209,15 @@ public CreateQueueResult createQueue(CreateQueueRequest request) {
214
209
}
215
210
216
211
static Optional <Long > getRetentionPeriod (Map <String , String > queueAttributes ) {
217
- return Optional .ofNullable (queueAttributes .remove (IDLE_QUEUE_RETENTION_PERIOD ))
212
+ return Optional .ofNullable (queueAttributes .remove (Constants . IDLE_QUEUE_RETENTION_PERIOD ))
218
213
.map (Long ::parseLong )
219
214
.map (AmazonSQSIdleQueueDeletingClient ::checkQueueRetentionPeriodBounds );
220
215
}
221
216
222
217
static long checkQueueRetentionPeriodBounds (long retentionPeriod ) {
223
- if (retentionPeriod < MINIMUM_IDLE_QUEUE_RETENTION_PERIOD_SECONDS ) {
224
- throw new IllegalArgumentException ("The " + IDLE_QUEUE_RETENTION_PERIOD +
225
- " attribute bigger or equal to " + MINIMUM_IDLE_QUEUE_RETENTION_PERIOD_SECONDS + " seconds" );
218
+ if (retentionPeriod < Constants . MINIMUM_IDLE_QUEUE_RETENTION_PERIOD_SECONDS ) {
219
+ throw new IllegalArgumentException ("The " + Constants . IDLE_QUEUE_RETENTION_PERIOD +
220
+ " attribute bigger or equal to " + Constants . MINIMUM_IDLE_QUEUE_RETENTION_PERIOD_SECONDS + " seconds" );
226
221
}
227
222
return retentionPeriod ;
228
223
}
0 commit comments