Quarkus & REST Clients

477 views
Skip to first unread message

David Hoffer

unread,
Sep 8, 2021, 12:22:01 PM9/8/21
to Quarkus Development mailing list
I'm following the following guides regarding having Quarkus mange our REST clients.


However the examples show the Path to be provided either in code/annotations and/or in Quarkus application.properties.  In our case the base path is provided by our configuration not Quarkus as it depends on the install network/etc configs.  

How can we use Quarkus to manage the client when the path is a variable from our configs?

-Dave

Georgios Andrianakis

unread,
Sep 8, 2021, 12:48:01 PM9/8/21
to David Hoffer, Quarkus Development mailing list
You mean that variable is not coming from configuration?

In any case, one can use the REST Client programmatically as shown at: https://quarkus.io/guides/rest-client-reactive#programmatic-client-creation-with-restclientbuilder (the section is in the Reactive REST Client guide, but the feature is actually a MicroProfile REST Client feature, so it works for both the reactive and non-reactive clients)

-Dave

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/f8fa0a06-e6a2-4762-b9b8-6ba8093541c0n%40googlegroups.com.

David Hoffer

unread,
Sep 8, 2021, 4:07:48 PM9/8/21
to Quarkus Development mailing list
Yes its coming from configuration but ours not Quarkus, we maintain deployment/runtime configs in Zookeeper so all nodes get updated in realtime.

Yes creating the REST Client programmatically is what I need here but it seems there is a problem with it reading path params.  Actually two separate problems.

Problem 1:
@Path("{currentUserId}/{fileName}")
Response sendFile( String currentUserId,
                   String fileName,
   @BeanParam() MultipartBody body);
Here it thinks I have no path variables but from the docs my understanding is that if my variable name matches the Path annotation name then I don't need to annotate with @PathParam.

Problem 2:
@Path("{currentUserId}/{fileName}")
Response sendFile( @PathParam(value = "currentUserId") String currentUserId,
                   @PathParam(value = "fileName") String fileName,
   @BeanParam() MultipartBody body);
Here I go ahead and add @PathParam to solve the prior problem but it still fails because the QuarkusRestClientBuilder#verifyInterface method only files one path variable in @Path.  It only files the last one (fileName)

Have I defined this incorrectly?

-Dave

Georgios Andrianakis

unread,
Sep 8, 2021, 4:25:12 PM9/8/21
to David Hoffer, Michal Szynkiewicz, Quarkus Development mailing list
On Wed, Sep 8, 2021 at 11:08 PM David Hoffer <dhof...@gmail.com> wrote:
Yes its coming from configuration but ours not Quarkus, we maintain deployment/runtime configs in Zookeeper so all nodes get updated in realtime.

Yes creating the REST Client programmatically is what I need here but it seems there is a problem with it reading path params.  Actually two separate problems.

Problem 1:
@Path("{currentUserId}/{fileName}")
Response sendFile( String currentUserId,
                   String fileName,
   @BeanParam() MultipartBody body);
Here it thinks I have no path variables but from the docs my understanding is that if my variable name matches the Path annotation name then I don't need to annotate with @PathParam.

That is only true for the reactive REST Client (which is based on RESTEasy Reactive code that has this facility).

Problem 2:
@Path("{currentUserId}/{fileName}")
Response sendFile( @PathParam(value = "currentUserId") String currentUserId,
                   @PathParam(value = "fileName") String fileName,
   @BeanParam() MultipartBody body);
Here I go ahead and add @PathParam to solve the prior problem but it still fails because the QuarkusRestClientBuilder#verifyInterface method only files one path variable in @Path.  It only files the last one (fileName)

I don't know about this one. @Michal Szynkiewicz can likely shine some light on this.

Have I defined this incorrectly?

-Dave

On Wednesday, September 8, 2021 at 10:48:01 AM UTC-6 gand...@redhat.com wrote:
On Wed, Sep 8, 2021 at 7:22 PM David Hoffer <dhof...@gmail.com> wrote:
I'm following the following guides regarding having Quarkus mange our REST clients.


However the examples show the Path to be provided either in code/annotations and/or in Quarkus application.properties.  In our case the base path is provided by our configuration not Quarkus as it depends on the install network/etc configs.  

How can we use Quarkus to manage the client when the path is a variable from our configs?

You mean that variable is not coming from configuration?

In any case, one can use the REST Client programmatically as shown at: https://quarkus.io/guides/rest-client-reactive#programmatic-client-creation-with-restclientbuilder (the section is in the Reactive REST Client guide, but the feature is actually a MicroProfile REST Client feature, so it works for both the reactive and non-reactive clients)

-Dave

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/f8fa0a06-e6a2-4762-b9b8-6ba8093541c0n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.

David Hoffer

unread,
Sep 8, 2021, 4:37:33 PM9/8/21
to Quarkus Development mailing list
Btw, I'm using 2.1.4.Final

David Hoffer

unread,
Sep 8, 2021, 5:32:18 PM9/8/21
to Quarkus Development mailing list
The problem seems to be here (well actually prior to here):

@Override
public List<String> getPathParamNamesInDeclarationOrder()
{
List<String> params = new ArrayList<String>();
HashSet<String> set = new HashSet<String>();
if (scheme != null) addToPathParamList(params, set, scheme);
if (userInfo != null) addToPathParamList(params, set, userInfo);
if (host != null) addToPathParamList(params, set, host);
if (path != null) addToPathParamList(params, set, path);
if (query != null) addToPathParamList(params, set, query);
if (fragment != null) addToPathParamList(params, set, fragment);

return params;
}

The problem is that the 'path' instance variable is incorrect.  It just has the last of the path variables.

Georgios Andrianakis

unread,
Sep 9, 2021, 12:49:07 AM9/9/21
to David Hoffer, Quarkus Development mailing list
Please open an issue

Michał Szynkiewicz

unread,
Sep 9, 2021, 3:27:22 AM9/9/21
to Georgios Andrianakis, David Hoffer, Quarkus Development mailing list


czw., 9 wrz 2021 o 06:49 Georgios Andrianakis <gand...@redhat.com> napisał(a):
Please open an issue
+1, with a minimal reproducer, please : ) 


Also, have you tried rest-client-reactive?


David Hoffer

unread,
Sep 10, 2021, 2:46:42 PM9/10/21
to Quarkus Development mailing list
Reply all
Reply to author
Forward
0 new messages