quarkiverse / quarkus-amazon-services

Quarkus Amazon Services extensions
Apache License 2.0
41 stars 48 forks source link

Integration with Smallrye Reactive Messaging SQS #1414

Open adampoplawski opened 4 days ago

adampoplawski commented 4 days ago

Around April SQS support was added to Smallrye Reactive Messaging. I asked on Zulip if Quarkus integration is planned and were transferred here. Is this topic considered? For potential reference https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/smallrye.20reactive.20messaging.20SQS.20support. image

Thx for support

scrocquesel commented 4 days ago

@adampoplawski smallrye is supported directly by quarkus core. I would open an issue there. Smallrye use only the netty transport implementation so that the whole purpose of this extension is a bit over complicated. I guess like for Apache Camel aws2 SQS which only use Apache HTTP client transport, there will be a dedicated and separated extension for smallrye.

The only things that should be needed for quarkus to support aws sdk with netty-io-client is

@BuildStep
    void runtimeInitialize(BuildProducer<RuntimeInitializedClassBuildItem> producer) {
        producer.produce(
                new RuntimeInitializedClassBuildItem("software.amazon.awssdk.core.retry.backoff.FullJitterBackoffStrategy"));
        producer.produce(
                new RuntimeInitializedClassBuildItem("software.amazon.awssdk.utils.cache.CachedSupplier"));
    }

a copy of https://github.com/quarkiverse/quarkus-amazon-services/blob/main/common/runtime/src/main/java/io/quarkus/amazon/common/runtime/CrtSubstitutions.java

and a dependency on io.quarkus:quarkus-netty.

Last, like with the Apache Camel connector, you may be able to reuse an instance from this extension as the smallrye connector allows to inject an SqsClient instance.

@ozangunalp what do you think ?

ozangunalp commented 3 days ago

I'll respond here first:

The connector was contributed upstream to the Smallrye Reactive Messaging, but it was designed to work with a provided SqsAsyncClient instance, for example by the Quarkus AWS extension.

The integration is very straightforward, as @scrocquesel mentioned. There is a quickstart here: https://github.com/quarkusio/quarkus-quickstarts/tree/main/amazon-sqs-connector-quickstart

With the following dependencies :

    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-messaging</artifactId>
    </dependency>
    <dependency>
      <groupId>io.quarkiverse.amazonservices</groupId>
      <artifactId>quarkus-amazon-sqs</artifactId>
    </dependency>
    <dependency>
      <groupId>io.smallrye.reactive</groupId>
      <artifactId>smallrye-reactive-messaging-aws-sqs</artifactId>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>url-connection-client</artifactId>
    </dependency>
    <dependency>
      <groupId>software.amazon.awssdk</groupId>
      <artifactId>netty-nio-client</artifactId>
    </dependency>

We could contribute to this repository, an extension putting all these dependencies together. @adampoplawski I can help if you are willing to contribute.

scrocquesel commented 3 days ago

If we don't need a specific quarkus extension for the connector itself, it is all good.

Is it documented somewhere that not all smallrye connectors require a quarkus extension.

ozangunalp commented 3 days ago

Is it documented somewhere that not all smallrye connectors require a quarkus extension.

Maybe I'll add a line in https://quarkus.io/guides/messaging about that.