You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @NumFive5 – thanks for opening the issue! Are you looking to integrate the Java SDK with Feign? If so, could you provide more details on what you're trying to achieve?
Edit: I have just checking out the code of Dapr java-sdk and found that It changed a lot for dapr-spring-boot-starter, so it will be not usable for the repo above. So the repo is now archived.
@lony2003 can you please share here some examples on how Feign clients would be used? I like the idea of simplifying the service to service communication with a declarative client, but I just don't see how this will work in practice. This might be my lack of experience with Feign, so a code example in this issue would help a lot.
@ServicepublicclassGfbServiceImplimplementsIGfbService {
privatefinalGridFeedbackFeignClientgridFeedbackFeignClient;
publicGfbServiceImpl(GridFeedbackFeignClientgridFeedbackFeignClient) {
this.gridFeedbackFeignClient = gridFeedbackFeignClient;
}
@OverridepublicPageResult<List<GridFeedbackDTO>> getAllByUser(Integerpage, IntegerpageSize, Stringtoken) {
HttpHeadersheaders = newHttpHeaders();
headers.setBearerAuth(token);
Result<PageResult<List<GridFeedbackDTO>>> result = gridFeedbackFeignClient.getAllByUser(page, pageSize, headers);
if (!result.isSuccess()) {
thrownewResultException("can not get GFB by user", ResultCode.getByValue(result.getCode()));
}
returnresult.getData();
}
@OverridepublicGridFeedbackDTOupdateGridFeedback(UpdateGridFeedbackDTOcommand, Stringtoken) {
HttpHeadersheaders = newHttpHeaders();
headers.setBearerAuth(token);
Result<GridFeedbackDTO> result = gridFeedbackFeignClient.updateGridFeedback(command, headers);
if (!result.isSuccess()) {
thrownewResultException("can not get GFB by user", ResultCode.getByValue(result.getCode()));
}
returnresult.getData();
}
}
As Spring Cloud Openfeign has a check of http:// and https:// protocol, the url of dapr feign client must be start with http:// or https://, as there is no need to specify TLS for Dapr RPC, I'd like to use http:// protocol for that (in fact, it's just a meaningless placeholder, so never mind that problem).
Note that the path parameters like ?a=a&b=b not work, as dapr grpc will urlencode it, don't know if it's my problem for that.
To get Dapr Invoke works with Spring Cloud Openfeign, we would create a Targeter (a interface in Spring Cloud Openfeign) to handle @UseDaprClient annoation, and use @Bean @Primary or @Bean to cover the default Targeter defined in Spring Cloud Openfeign as it defined with @Bean @ConditionOnMissingBean, but I think it may not be suitable for a library (especially for a official library) to have a bean that replace a bean from other libraries, so I wonder your opinion.
Activity
cicoyle commentedon Jan 31, 2025
Hi @NumFive5 – thanks for opening the issue! Are you looking to integrate the Java SDK with Feign? If so, could you provide more details on what you're trying to achieve?
lony2003 commentedon Mar 3, 2025
I wrote a frign client for dapr and springboot, you can try this: https://github.com/fangkehou-team/dapr-spring
Edit: I have just checking out the code of Dapr java-sdk and found that It changed a lot for dapr-spring-boot-starter, so it will be not usable for the repo above. So the repo is now archived.
salaboy commentedon Mar 19, 2025
@lony2003 can you please share here some examples on how Feign clients would be used? I like the idea of simplifying the service to service communication with a declarative client, but I just don't see how this will work in practice. This might be my lack of experience with Feign, so a code example in this issue would help a lot.
lony2003 commentedon Mar 20, 2025
@salaboy just like this example in my project:
Feign client defined here:
And usage of the client is here:
As Spring Cloud Openfeign has a check of
http://
andhttps://
protocol, the url of dapr feign client must be start withhttp://
orhttps://
, as there is no need to specify TLS for Dapr RPC, I'd like to usehttp://
protocol for that (in fact, it's just a meaningless placeholder, so never mind that problem).I defined the protocol like
http://method.<appId>/<methodName>
forinvokeMethod
andhttp://binding.<bindingName>/<operation>
forinvokeBinding
, please check https://dapr-spring.fangkehou.icu/en/feign/getting-started.html#about-feign-dapr-client for more details.It can also be used like https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/#creating-feign-clients-manually , just replace the client to
DaprInvokeFeignClient
.Note that the path parameters like
?a=a&b=b
not work, as dapr grpc will urlencode it, don't know if it's my problem for that.To get Dapr Invoke works with Spring Cloud Openfeign, we would create a
Targeter
(a interface in Spring Cloud Openfeign) to handle@UseDaprClient
annoation, and use@Bean @Primary
or@Bean
to cover the default Targeter defined in Spring Cloud Openfeign as it defined with@Bean @ConditionOnMissingBean
, but I think it may not be suitable for a library (especially for a official library) to have a bean that replace a bean from other libraries, so I wonder your opinion.