Skip to content

Commit

Permalink
Merge pull request #140 from seanliu-oss/make-WAIT_TIME_SECONDS-modif…
Browse files Browse the repository at this point in the history
…iable

Make wait time seconds modifiable
  • Loading branch information
ziyanli-amazon authored Dec 6, 2022
2 parents c6f742e + c9fe063 commit 24e8dae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@
* This runs until the message consumer is closed and in-progress SQS
* <code>receiveMessage</code> call returns.
* <P>
* Uses SQS <code>receiveMessage</code> with long-poll wait time of 20 seconds.
* Uses SQS <code>receiveMessage</code> with long-poll wait time of WAIT_TIME_SECONDS (default to 20) seconds.
* <P>
* Add re-tries on top of <code>SqsClient</code> re-tries on SQS calls.
*/
public class SQSMessageConsumerPrefetch implements Runnable, PrefetchManager {

private static final Logger LOG = LoggerFactory.getLogger(SQSMessageConsumerPrefetch.class);

protected static final int WAIT_TIME_SECONDS = 20;
protected static int WAIT_TIME_SECONDS = 20;

protected static final String ALL = "All";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.amazon.sqs.javamessaging;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;

import static org.junit.jupiter.api.Assertions.*;

class ModifyWaitTimeSecondsTest {
@DisplayName("Should be able to modify SQSMessageConsumerPrefetch.WAIT_TIME_SECONDS via Reflection")
@Test
void WaitTimeSecondsShouldBeModifiableViaReflection() throws NoSuchFieldException, IllegalAccessException {
Field wait_time_seconds = SQSMessageConsumerPrefetch.class.getDeclaredField("WAIT_TIME_SECONDS");
wait_time_seconds.setAccessible(true);
wait_time_seconds.setInt(null,5);
assertEquals(5,SQSMessageConsumerPrefetch.WAIT_TIME_SECONDS);
}
}

0 comments on commit 24e8dae

Please sign in to comment.