Skip to content
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
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -101,7 +101,7 @@ protected AbstractContainerOptions(Builder<?, ?> builder) {
this.observationRegistry = builder.observationRegistry;
this.observationConvention = builder.observationConvention;
Assert.isTrue(this.maxMessagesPerPoll <= this.maxConcurrentMessages, String.format(
"messagesPerPoll should be less than or equal to maxConcurrentMessages. Values provided: %s and %s respectively",
"maxMessagesPerPoll should be less than or equal to maxConcurrentMessages. Values provided: %s and %s respectively",
this.maxMessagesPerPoll, this.maxConcurrentMessages));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@
package io.awspring.cloud.sqs.listener;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
import static org.mockito.Mockito.mock;

import io.awspring.cloud.sqs.listener.acknowledgement.AcknowledgementOrdering;
Expand All @@ -29,6 +30,8 @@
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.core.task.TaskExecutor;
import org.springframework.retry.backoff.BackOffPolicy;
import org.springframework.retry.backoff.BackOffPolicyBuilder;
Expand All @@ -39,6 +42,7 @@
* Tests for {@link SqsContainerOptions}.
*
* @author Tomaz Fernandes
* @author Richard Fearn
*/
class ContainerOptionsTests {

Expand Down Expand Up @@ -143,6 +147,30 @@ void shouldDefaultToNoopObservationRegistry() {
assertThat(options.getObservationRegistry().isNoop()).isTrue();
}

@ParameterizedTest
@ValueSource(ints = { 4, 5 })
void shouldAcceptValidMaxMessagesPerPoll(final int maxMessagesPerPoll) {

final SqsContainerOptions options = SqsContainerOptions.builder()
.maxMessagesPerPoll(maxMessagesPerPoll)
.maxConcurrentMessages(5)
.build();

assertThat(options.getMaxMessagesPerPoll()).isEqualTo(maxMessagesPerPoll);
assertThat(options.getMaxConcurrentMessages()).isEqualTo(5);
}

@Test
void shouldRejectInvalidMaxMessagesPerPoll() {

final Throwable exception = catchThrowable(
() -> SqsContainerOptions.builder().maxMessagesPerPoll(6).maxConcurrentMessages(5).build());

assertThat(exception).isInstanceOf(IllegalArgumentException.class)
.hasMessage("maxMessagesPerPoll should be less than or equal to maxConcurrentMessages. "
+ "Values provided: 6 and 5 respectively");
}

private SqsContainerOptions createConfiguredOptions() {
return createConfiguredBuilder().build();
}
Expand Down