Skip to content
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

Make wait time seconds modifiable #140

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}