-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQS ack and failure handlers (#2903)
- Loading branch information
1 parent
dbaa3a6
commit 0c212c1
Showing
21 changed files
with
675 additions
and
45 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
36 changes: 36 additions & 0 deletions
36
documentation/src/main/java/sqs/inbound/SqsCustomAckStrategy.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,36 @@ | ||
package sqs.inbound; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import io.smallrye.common.annotation.Identifier; | ||
import io.smallrye.mutiny.Uni; | ||
import io.smallrye.reactive.messaging.aws.sqs.SqsAckHandler; | ||
import io.smallrye.reactive.messaging.aws.sqs.SqsConnectorIncomingConfiguration; | ||
import io.smallrye.reactive.messaging.aws.sqs.SqsMessage; | ||
import io.vertx.mutiny.core.Vertx; | ||
import software.amazon.awssdk.services.sqs.SqsAsyncClient; | ||
|
||
public class SqsCustomAckStrategy implements SqsAckHandler { | ||
|
||
@ApplicationScoped | ||
@Identifier("custom") | ||
public static class Factory implements SqsAckHandler.Factory { | ||
|
||
@Override | ||
public SqsAckHandler create(SqsConnectorIncomingConfiguration conf, | ||
Vertx vertx, | ||
SqsAsyncClient client, | ||
Uni<String> queueUrlUni, | ||
BiConsumer<Throwable, Boolean> reportFailure) { | ||
return new SqsCustomAckStrategy(); | ||
} | ||
} | ||
|
||
@Override | ||
public Uni<Void> handle(SqsMessage<?> message) { | ||
return Uni.createFrom().voidItem() | ||
.emitOn(message::runOnMessageContext); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
documentation/src/main/java/sqs/inbound/SqsCustomNackStrategy.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,33 @@ | ||
package sqs.inbound; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.eclipse.microprofile.reactive.messaging.Metadata; | ||
|
||
import io.smallrye.common.annotation.Identifier; | ||
import io.smallrye.mutiny.Uni; | ||
import io.smallrye.reactive.messaging.aws.sqs.SqsFailureHandler; | ||
import io.smallrye.reactive.messaging.aws.sqs.SqsMessage; | ||
import software.amazon.awssdk.services.sqs.SqsAsyncClient; | ||
|
||
public class SqsCustomNackStrategy implements SqsFailureHandler { | ||
|
||
@ApplicationScoped | ||
@Identifier("custom") | ||
public static class Factory implements SqsFailureHandler.Factory { | ||
|
||
@Override | ||
public SqsFailureHandler create(String channel, SqsAsyncClient client, Uni<String> queueUrlUni, | ||
BiConsumer<Throwable, Boolean> reportFailure) { | ||
return new SqsCustomNackStrategy(); | ||
} | ||
} | ||
|
||
@Override | ||
public Uni<Void> handle(SqsMessage<?> message, Metadata metadata, Throwable throwable) { | ||
return Uni.createFrom().voidItem() | ||
.emitOn(message::runOnMessageContext); | ||
} | ||
} |
25 changes: 24 additions & 1 deletion
25
...messaging-aws-sqs/src/main/java/io/smallrye/reactive/messaging/aws/sqs/SqsAckHandler.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 |
---|---|---|
@@ -1,9 +1,32 @@ | ||
package io.smallrye.reactive.messaging.aws.sqs; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
import io.vertx.mutiny.core.Vertx; | ||
import software.amazon.awssdk.services.sqs.SqsAsyncClient; | ||
|
||
public interface SqsAckHandler { | ||
|
||
Uni<Void> handle(SqsMessage message); | ||
interface Strategy { | ||
String DELETE = "delete"; | ||
String IGNORE = "ignore"; | ||
} | ||
|
||
interface Factory { | ||
SqsAckHandler create(SqsConnectorIncomingConfiguration conf, Vertx vertx, SqsAsyncClient client, | ||
Uni<String> queueUrlUni, | ||
BiConsumer<Throwable, Boolean> reportFailure); | ||
} | ||
|
||
default Uni<SqsMessage<?>> received(SqsMessage<?> message) { | ||
return Uni.createFrom().item(message); | ||
} | ||
|
||
Uni<Void> handle(SqsMessage<?> message); | ||
|
||
default void close(boolean graceful) { | ||
|
||
} | ||
|
||
} |
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
25 changes: 25 additions & 0 deletions
25
...aging-aws-sqs/src/main/java/io/smallrye/reactive/messaging/aws/sqs/SqsFailureHandler.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,25 @@ | ||
package io.smallrye.reactive.messaging.aws.sqs; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
import org.eclipse.microprofile.reactive.messaging.Metadata; | ||
|
||
import io.smallrye.mutiny.Uni; | ||
import software.amazon.awssdk.services.sqs.SqsAsyncClient; | ||
|
||
public interface SqsFailureHandler { | ||
|
||
interface Strategy { | ||
String DELETE = "delete"; | ||
String VISIBILITY = "visibility"; | ||
String FAIL = "fail"; | ||
String IGNORE = "ignore"; | ||
} | ||
|
||
interface Factory { | ||
SqsFailureHandler create(String channel, SqsAsyncClient client, Uni<String> queueUrlUni, | ||
BiConsumer<Throwable, Boolean> reportFailure); | ||
} | ||
|
||
Uni<Void> handle(SqsMessage<?> message, Metadata metadata, Throwable throwable); | ||
} |
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
Oops, something went wrong.