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
2 changes: 2 additions & 0 deletions .github/workflows/cd-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
publish:
environment: ${{ inputs.environment }}
runs-on: ubuntu-latest
env:
MAVEN_ARGS: "--no-transfer-progress"
steps:
- name: Checkout repository
uses: actions/checkout@v6
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cd-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
variables:
if: ${{ github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
env:
MAVEN_ARGS: "--no-transfer-progress"
outputs:
version: ${{ steps.environment.outputs.version }}
target-branch: ${{ steps.environment.outputs.target-branch }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci-gates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ jobs:
sonarcloud:
environment: sonarcloud
runs-on: ubuntu-latest
env:
MAVEN_ARGS: "--no-transfer-progress"
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: 17
java-version: 21
distribution: "corretto"
cache: "maven"

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
MAVEN_ARGS: "--no-transfer-progress"
strategy:
matrix:
java-version: [8, 11, 17, 21, 25]
Expand All @@ -32,6 +34,8 @@ jobs:

test:
runs-on: ubuntu-latest
env:
MAVEN_ARGS: "--no-transfer-progress"
strategy:
matrix:
java-version: [8, 11, 17, 21, 25]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- feature/**
- fix/**
- dependabot/maven/**

env:
TYPE: ${{ startsWith(github.ref_name, 'feature') && 'Feature' || 'Fix'}}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _**Compatible AWS JDK v1 >= 1.12**_

_**Compatible AWS JDK v2 >= 2.18**_

This library supports **`Kotlin`** aswell
This library supports **`Kotlin`** as well

## 1. Quick Start

Expand Down
2 changes: 1 addition & 1 deletion amazon-sqs-java-messaging-lib-template/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.mvallim</groupId>
<artifactId>amazon-sqs-java-messaging-lib</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand All @@ -31,7 +31,6 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.LockSupport;
import java.util.function.BiFunction;
import java.util.function.UnaryOperator;

Expand Down Expand Up @@ -63,6 +62,7 @@
* @param <O> the publish batch result type
* @param <E> the request entry payload type
*/
@SuppressWarnings("java:S135")
abstract class AbstractAmazonSqsConsumer<C, R, O, E> implements Runnable, AmazonSqsConsumer<R, O> {

/**
Expand Down Expand Up @@ -278,7 +278,7 @@ private boolean canAddPayload(final int batchSizeBytes) {
@SneakyThrows
private Optional<R> createBatch(final BlockingQueue<RequestEntry<E>> requests) {
final AtomicInteger batchSizeBytes = new AtomicInteger(0);
final List<RequestEntryInternal> requestEntries = new LinkedList<>();
final List<RequestEntryInternal> requestEntries = new ArrayList<>(queueProperty.getMaxBatchSize());

while (canAddToBatch(batchSizeBytes.get(), requestEntries.size(), requests.peek())) {
final RequestEntry<E> request = requests.peek();
Expand All @@ -299,7 +299,8 @@ private Optional<R> createBatch(final BlockingQueue<RequestEntry<E>> requests) {

final String stringPayload = new String(payload, StandardCharsets.UTF_8);

final String message = String.format("The maximum allowed message size exceeding 1024KB (1,048,576 bytes). Payload: %s, Headers: %s", stringPayload, request.getMessageHeaders());
final String message = String.format("The maximum allowed message size exceeding 1024KB (1,048,576 bytes). Payload: %s, Headers: %s",
stringPayload, request.getMessageHeaders());

handleError(publishBatchRequest, new MaximumAllowedMessageException(message, requests.take()));

Expand All @@ -309,8 +310,11 @@ private Optional<R> createBatch(final BlockingQueue<RequestEntry<E>> requests) {
continue;
}

if (canAddPayload(batchSizeBytes.addAndGet(messageSize))) {
if (canAddPayload(batchSizeBytes.get() + messageSize)) {
requestEntries.add(requestEntryInternalFactory.create(requests.take(), payload));
batchSizeBytes.addAndGet(messageSize);
} else {
break;
}
}

Expand All @@ -337,8 +341,13 @@ private Optional<R> createBatch(final BlockingQueue<RequestEntry<E>> requests) {
@SneakyThrows
public CompletableFuture<Void> await() {
return CompletableFuture.runAsync(() -> {
while (MapUtils.isNotEmpty(this.pendingRequests) || CollectionUtils.isNotEmpty(this.queueRequests)) {
LockSupport.parkNanos(Duration.ofMillis(queueProperty.getLinger()).toNanos());
while (MapUtils.isNotEmpty(pendingRequests) || CollectionUtils.isNotEmpty(queueRequests)) {
try {
TimeUnit.NANOSECONDS.sleep(Duration.ofMillis(queueProperty.getLinger()).toNanos());
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.warn("await() interrupted");
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
abstract class AbstractAmazonSqsProducer<E> implements AmazonSqsProducer<E> {

private final AtomicReference<State> state = new AtomicReference<>(State.RUNNIG);
private final AtomicReference<State> state = new AtomicReference<>(State.RUNNING);

private final ConcurrentMap<String, ListenableFuture<ResponseSuccessEntry, ResponseFailEntry>> pendingRequests;

Expand All @@ -53,7 +53,7 @@ abstract class AbstractAmazonSqsProducer<E> implements AmazonSqsProducer<E> {
@Override
@SneakyThrows
public ListenableFuture<ResponseSuccessEntry, ResponseFailEntry> send(final RequestEntry<E> requestEntry) {
if (State.RUNNIG.equals(state.get())) {
if (State.RUNNING.equals(state.get())) {
return enqueueRequest(requestEntry);
} else {
final ListenableFutureImpl listenableFutureImpl = new ListenableFutureImpl();
Expand All @@ -75,7 +75,7 @@ public ListenableFuture<ResponseSuccessEntry, ResponseFailEntry> send(final Requ
*/
@Override
public void shutdown() {
state.compareAndSet(State.RUNNIG, State.SHUTDOWN);
state.compareAndSet(State.RUNNING, State.SHUTDOWN);
}

/**
Expand All @@ -96,7 +96,7 @@ private ListenableFuture<ResponseSuccessEntry, ResponseFailEntry> enqueueRequest
* Lifecycle states of the producer.
*/
enum State {
RUNNIG, SHUTDOWN
RUNNING, SHUTDOWN
}

}
2 changes: 1 addition & 1 deletion amazon-sqs-java-messaging-lib-v1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.mvallim</groupId>
<artifactId>amazon-sqs-java-messaging-lib</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion amazon-sqs-java-messaging-lib-v2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.github.mvallim</groupId>
<artifactId>amazon-sqs-java-messaging-lib</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.mvallim</groupId>
<artifactId>amazon-sqs-java-messaging-lib</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.2-SNAPSHOT</version>
<packaging>pom</packaging>

<name>${project.artifactId}</name>
Expand Down
Loading