-
Notifications
You must be signed in to change notification settings - Fork 211
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
Use With Feign #1181
Comments
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? |
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. |
@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. |
@salaboy just like this example in my project: Feign client defined here: @UseDaprClient
@FeignClient(name = "grid-feign", url = "http://method.nep-back-gfb-spring/gfb")
public interface GridFeedbackFeignClient {
@GetMapping(path = "/list/byUser/{pageSize}/{page}", consumes = "application/json;charset=utf-8", produces = "application/json;charset=utf-8")
Result<PageResult<List<GridFeedbackDTO>>> getAllByUser(
@PathVariable Integer page,
@PathVariable Integer pageSize,
@RequestHeader HttpHeaders headers
);
@PostMapping(path = "/update", consumes = "application/json;charset=utf-8", produces = "application/json;charset=utf-8")
Result<GridFeedbackDTO> updateGridFeedback(
@RequestBody UpdateGridFeedbackDTO command,
@RequestHeader HttpHeaders headers
);
} And usage of the client is here: @Service
public class GfbServiceImpl implements IGfbService {
private final GridFeedbackFeignClient gridFeedbackFeignClient;
public GfbServiceImpl(GridFeedbackFeignClient gridFeedbackFeignClient) {
this.gridFeedbackFeignClient = gridFeedbackFeignClient;
}
@Override
public PageResult<List<GridFeedbackDTO>> getAllByUser(Integer page, Integer pageSize, String token) {
HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(token);
Result<PageResult<List<GridFeedbackDTO>>> result = gridFeedbackFeignClient.getAllByUser(page, pageSize, headers);
if (!result.isSuccess()) {
throw new ResultException("can not get GFB by user", ResultCode.getByValue(result.getCode()));
}
return result.getData();
}
@Override
public GridFeedbackDTO updateGridFeedback(UpdateGridFeedbackDTO command, String token) {
HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(token);
Result<GridFeedbackDTO> result = gridFeedbackFeignClient.updateGridFeedback(command, headers);
if (!result.isSuccess()) {
throw new ResultException("can not get GFB by user", ResultCode.getByValue(result.getCode()));
}
return result.getData();
}
} As Spring Cloud Openfeign has a check of I defined the protocol like 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 Note that the path parameters like To get Dapr Invoke works with Spring Cloud Openfeign, we would create a |
Describe the proposal
The text was updated successfully, but these errors were encountered: