Reputation: 11
i have an api gateway and an auth microservice, the gateway to validate the token calls the auth service via feign in this fashion:
boolean isValidToken = authClient.validateToken(token);
but the IDE signlas this as a blocking action, i looked more into it and found i could use reactive feign:
<dependency>
<groupId>com.playtika.reactivefeign</groupId>
<artifactId>feign-reactor-spring-cloud-starter</artifactId>
</dependency>
but despite the IDE finding the dependency maven can't downlaod it.
so besides this is there a better way to handle this scenario? message brokers would be a bad approach with the nature of the request.
Upvotes: 1
Views: 62
Reputation: 86
To download the dependency, maven will need a version tag. This would be the most recent version:
<dependency>
<groupId>com.playtika.reactivefeign</groupId>
<artifactId>feign-reactor-spring-cloud-starter</artifactId>
<version>4.2.1</version>
</dependency>
As mentioned by @rzwitzerloot, if you wanted to deal with the cause of the issue, you'd have to rewrite this in a reactive way, passing in success and failure callbacks to the token validation.
That may be a nontrivial rewrite, so you might want to first establish whether thread starvation is a relevant issue in your specific setup.
If you prefer the blocking style, you might get similar performance and eliminate starvation by using virtual threads.
Upvotes: 0