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

fix: Timeout settings in SqsTemplate #1250

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -602,11 +602,11 @@ private ReceiveMessageRequest doCreateReceiveMessageRequest(Duration pollTimeout
ReceiveMessageRequest.Builder builder = ReceiveMessageRequest.builder().queueUrl(attributes.getQueueUrl())
.maxNumberOfMessages(maxNumberOfMessages).messageAttributeNames(this.messageAttributeNames)
.attributeNamesWithStrings(this.messageSystemAttributeNames)
.waitTimeSeconds(pollTimeout.toSecondsPart());
.waitTimeSeconds(pollTimeout.toSeconds());
if (additionalHeaders.containsKey(SqsHeaders.SQS_VISIBILITY_TIMEOUT_HEADER)) {
builder.visibilityTimeout(
getValueAs(additionalHeaders, SqsHeaders.SQS_VISIBILITY_TIMEOUT_HEADER, Duration.class)
.toSecondsPart());
.toSeconds());
}
if (additionalHeaders.containsKey(SqsHeaders.SQS_RECEIVE_REQUEST_ATTEMPT_ID_HEADER)) {
builder.receiveRequestAttemptId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ void shouldReceiveFromOptions() {
.willReturn(CompletableFuture.completedFuture(deleteResponse));
SqsOperations template = SqsTemplate.newSyncTemplate(mockClient);
Optional<Message<String>> receivedMessage = template.receive(from -> from.queue(queue)
.pollTimeout(Duration.ofSeconds(1)).visibilityTimeout(Duration.ofSeconds(5))
.pollTimeout(Duration.ofSeconds(61)).visibilityTimeout(Duration.ofSeconds(65))
.additionalHeader(headerName1, headerValue1).additionalHeaders(Map.of(headerName2, headerValue2)),
String.class);
assertThat(receivedMessage).isPresent().hasValueSatisfying(message -> {
Expand All @@ -949,8 +949,8 @@ void shouldReceiveFromOptions() {
then(mockClient).should().receiveMessage(captor.capture());
ReceiveMessageRequest request = captor.getValue();
assertThat(request.maxNumberOfMessages()).isEqualTo(1);
assertThat(request.visibilityTimeout()).isEqualTo(5);
assertThat(request.waitTimeSeconds()).isEqualTo(1);
assertThat(request.visibilityTimeout()).isEqualTo(65);
assertThat(request.waitTimeSeconds()).isEqualTo(61);
}

@Test
Expand Down
Loading