-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add acknowledgement mode on @SqsListener annotation (#870)
* Add ack mode parameter to SqsListener annotation Fixes gh-761 * Remove unrelated file from PR * Fix style differences * Rename acknowledgement enum to be consistent with other nomenclatures * Update docs with @SqsListener acknowledgement mode param * Add JavaDoc for method and test enum value - Added missing JavaDoc for getAcknowledgementMode public method - Added test to ensure that new SqsListenerAcknowledgementMode enum will have the same values as the original AcknowledgementMode enum * Change annotation ack from enum to string - Change SqsListenerAcknowledgementMode from enum to class with const strings - Change typo on "acknowledgement" annotation field - Remove unnecessary field on SqsContainerOptionsBuilder - Move integration tests to its own test suite * Update documentation and code comments - Update docs to reflect new "DEFAULT" annotation ack mode - Update comments with latest changes * Set empty string as default behavior - Remove "DEFAULT" annotation acknowledgement mode, use empty string as default - Update docs * Add author after latest changes - Add author on modified classes * Fix inverted condition when resolving AcknowledgementMode value
- Loading branch information
João Victor Calassio
authored
Nov 4, 2023
1 parent
f7eb0ab
commit 273f8f9
Showing
9 changed files
with
572 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...ws-sqs/src/main/java/io/awspring/cloud/sqs/annotation/SqsListenerAcknowledgementMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2013-2023 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.awspring.cloud.sqs.annotation; | ||
|
||
import io.awspring.cloud.sqs.listener.acknowledgement.handler.AlwaysAcknowledgementHandler; | ||
import io.awspring.cloud.sqs.listener.acknowledgement.handler.NeverAcknowledgementHandler; | ||
import io.awspring.cloud.sqs.listener.acknowledgement.handler.OnSuccessAcknowledgementHandler; | ||
|
||
/** | ||
* Acknowledgement strategies supported by the {@link SqsListener} annotation. | ||
* | ||
* @author Joao Calassio | ||
* @since 3.1 | ||
* @see OnSuccessAcknowledgementHandler | ||
* @see AlwaysAcknowledgementHandler | ||
* @see NeverAcknowledgementHandler | ||
* @see io.awspring.cloud.sqs.listener.ContainerOptions | ||
* @see SqsListener | ||
*/ | ||
public class SqsListenerAcknowledgementMode { | ||
|
||
/** | ||
* Messages will be acknowledged when message processing is successful. | ||
*/ | ||
public static final String ON_SUCCESS = "ON_SUCCESS"; | ||
|
||
/** | ||
* Messages will be acknowledged whether processing was completed successfully or with an error. | ||
*/ | ||
public static final String ALWAYS = "ALWAYS"; | ||
|
||
/** | ||
* Messages will not be acknowledged automatically by the container. | ||
* @see io.awspring.cloud.sqs.listener.acknowledgement.Acknowledgement | ||
*/ | ||
public static final String MANUAL = "MANUAL"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...s/src/test/java/io/awspring/cloud/sqs/annotation/SqsListenerAcknowledgementModeTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2013-2023 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.awspring.cloud.sqs.annotation; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import io.awspring.cloud.sqs.listener.acknowledgement.handler.AcknowledgementMode; | ||
import java.lang.reflect.Field; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
|
||
/** | ||
* Tests for {@link SqsListenerAcknowledgementMode} enum values | ||
* | ||
* @author Joao Calassio | ||
*/ | ||
class SqsListenerAcknowledgementModeTests { | ||
|
||
@ParameterizedTest | ||
@EnumSource(AcknowledgementMode.class) | ||
void shouldHaveAllValuesOfAcknowledgementModeEnum(final AcknowledgementMode acknowledgementMode) | ||
throws NoSuchFieldException, IllegalAccessException { | ||
Class<SqsListenerAcknowledgementMode> clz = SqsListenerAcknowledgementMode.class; | ||
Field correspondingValue = clz.getDeclaredField(acknowledgementMode.name()); | ||
assertEquals(acknowledgementMode.name(), correspondingValue.get(clz)); | ||
} | ||
|
||
} |
Oops, something went wrong.