Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable HTTP compression for REST client only #46415

Closed
geoand opened this issue Feb 21, 2025 · 18 comments · Fixed by #46417
Closed

Enable HTTP compression for REST client only #46415

geoand opened this issue Feb 21, 2025 · 18 comments · Fixed by #46417
Labels
Milestone

Comments

@geoand
Copy link
Contributor

geoand commented Feb 21, 2025

Discussed in #46414

Originally posted by jdussouillez February 21, 2025
I have a REST API that acts like a middleware between clients and another "external" REST API.

To send requests to the external API, I use a REST client. I want to enable HTTP compression in the REST client, but not in my REST API. Mostly because I have a nginx in front of my REST API that handles compression so it's handled outside of the Quarkus app.

Is this possible?

From what I saw in the documentation, to enable HTTP compression in REST client, I have to use quarkus.http.enable-compression=true.

https://quarkus.io/guides/rest-client#receiving-compressed-messages

REST Client also supports receiving compressed messages using GZIP. You can enable the HTTP compression support by adding the property quarkus.http.enable-compression=true.

But this option will also enable global HTTP compression for my API: https://quarkus.io/guides/http-reference#http-compression

I might find some way to make what I want, but I'm wondering if there is a way to easily enable compression only for REST client.

Copy link

quarkus-bot bot commented Feb 21, 2025

/cc @cescoffier (rest-client)

@geoand
Copy link
Contributor Author

geoand commented Feb 21, 2025

@jdussouillez can you try #46417 please?

@jdussouillez
Copy link

jdussouillez commented Feb 21, 2025

I tried but unfortunately I need more time to figure out how to use your branch into my project.

I cloned your repo, switched your branch, run MAVEN_OPTS="-Xmx4g" ./mvnw install -Dquickly and followed https://github.com/quarkusio/quarkus/blob/main/CONTRIBUTING.md#updating-the-version by changing the group id and version, but I have some trouble with quarkus-rest-jackson dependency:

'dependencies.dependency.version' for io.quarkus:quarkus-rest-jackson:jar is missing

When explicitly adding <version>999-SNAPSHOT</version> on the dependency, I have a lot of cannot find symbol: class Inject build errors.

I'll find a solution and try ASAP

@geoand
Copy link
Contributor Author

geoand commented Feb 21, 2025

FWIW, when I build Quarkus locally I use:

mvn -T 1C -DskipDocs -DskipTests -DskipITs -Dinvoker.skip -DskipExtensionValidation -Dskip.gradle.tests -Dskip.gradle.build -Dtruststore.skip clean install -Prelocations

Then I use:

      <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-bom</artifactId>
        <version>999-SNAPSHOT</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

as the BOM in any test application

@jdussouillez
Copy link

FWIW, when I build Quarkus locally I use

It's not my day I think.

[ERROR] Failed to execute goal net.revelc.code:impsort-maven-plugin:1.7.0:sort (sort-imports) on project quarkus-enforcer-rules: Execution sort-imports of goal net.revelc.code:impsort-maven-plugin:1.7.0:sort failed: A required class was missing while executing net.revelc.code:impsort-maven-plugin:1.7.0:sort: null
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>net.revelc.code:impsort-maven-plugin:1.7.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/junior/.m2/repository/net/revelc/code/impsort-maven-plugin/1.7.0/impsort-maven-plugin-1.7.0.jar
[ERROR] urls[1] = file:/home/junior/.m2/repository/com/github/javaparser/javaparser-core/3.24.2/javaparser-core-3.24.2.jar
[ERROR] urls[2] = file:/home/junior/.m2/repository/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar
[ERROR] urls[3] = file:/home/junior/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar
[ERROR] urls[4] = file:/home/junior/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
[ERROR] urls[5] = file:/home/junior/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar
[ERROR] urls[6] = file:/home/junior/.m2/repository/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar
[ERROR] urls[7] = file:/home/junior/.m2/repository/com/google/errorprone/error_prone_annotations/2.11.0/error_prone_annotations-2.11.0.jar
[ERROR] urls[8] = file:/home/junior/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] : NoClassDefFoundError: org/codehaus/plexus/util/DirectoryScanner: org.codehaus.plexus.util.DirectoryScanner

@geoand
Copy link
Contributor Author

geoand commented Feb 21, 2025

What is the output of mvn -version?

I have:

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /home/gandrian/.sdkman/candidates/maven/current
Java version: 21.0.5, vendor: Eclipse Adoptium, runtime: /home/gandrian/.sdkman/candidates/java/21.0.5-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.19.0-50-generic", arch: "amd64", family: "unix"

@jdussouillez
Copy link

Same. I'm using SDKMan and switched to 17 (my apps are 21) to build Quarkus

Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /home/junior/.sdkman/candidates/maven/current
Java version: 17.0.14, vendor: Eclipse Adoptium, runtime: /home/junior/.sdkman/candidates/java/17.0.14-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.11.0-17-generic", arch: "amd64", family: "unix"

@geoand
Copy link
Contributor Author

geoand commented Feb 21, 2025

I am out of ideas unfortunately

@geoand
Copy link
Contributor Author

geoand commented Feb 24, 2025

New week, perhaps any luck on a new attempt to build this?

@jdussouillez
Copy link

jdussouillez commented Feb 24, 2025

Same as last week unfortunately. I checked and Quarkus 999-SNAPSHOT (built from your branch) is well installed in my .m2 (file modification date matches), but I have the same issues as last week.

I'm thinking about adding a temporary module in the Quarkus project. This module will contain a endpoint calling a REST client to test the new options you added. So I don't use "external" dependencies installed on my machine but the project modules themselves.

@geoand
Copy link
Contributor Author

geoand commented Feb 25, 2025

I rebased the PR onto main, maybe rerunning the build will magically succeed now :)

@jdussouillez
Copy link

maybe rerunning the build will magically succeed now :)

I was hoping, but same issues. Quarkus installation works fine, but I have a lot of errors when trying to use it.

I created a small repo to use HTTP compression on REST client here: https://github.com/jdussouillez/quarkus-rest-client-compression

But I can't build/start it using my local Quarkus.

@geoand
Copy link
Contributor Author

geoand commented Feb 25, 2025

In your sample, you need to use quarkus-rest-jackson instead of quarkus-resteasy-reactive-jackson

@geoand
Copy link
Contributor Author

geoand commented Feb 25, 2025

It tried it and it works for me

@jdussouillez
Copy link

In your sample, you need to use quarkus-rest-jackson instead of quarkus-resteasy-reactive-jackson

Yes I know, I tried some stuff.

One of my coworker could build it correctly so we'll stop investigating on my machine. I'll make him test it. I'll give some feedback very soon.

@geoand
Copy link
Contributor Author

geoand commented Feb 25, 2025

👍🏽

@geoand geoand closed this as completed in 9ba4ed8 Feb 25, 2025
geoand added a commit that referenced this issue Feb 25, 2025
Allow more fine-grained control of compression setting for REST Client
@quarkus-bot quarkus-bot bot added this to the 3.21 - main milestone Feb 25, 2025
@jdussouillez
Copy link

I tested it using https://github.com/jdussouillez/quarkus-rest-client-compression

I tested different configuration by switching on and off quarkus.http.enable-compression and quarkus.rest-client(.xxx).enable-compression and it works as expected! 🥳

Thanks for your help and the quick feature development!

@geoand
Copy link
Contributor Author

geoand commented Feb 26, 2025

Great, thanks for checking!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants