I have a scenario. My Microservice A is sending Kafka Message to ServiceB. Service B is consuming that message and after processing it is Sending update request to Service C.
I am sending Oauth token from Service A to Service B in kafka message field. How can I inject that token to All feign calls in Service B.
Related
If I want to send some request to a microservice under the gateway (for example, trigger by a timer), should I build a new WebClient, or just use an existing bean?
I have the following services
Service A - Sends request to service B using RestTemplate.
Service B - Has an end point that returns "Hello Universe".
Service G - "Spring Cloud Gateway".
Service A sends request to Service B using API Gateway URL using REST Template.
But, how does it work with Feign Client? For example below is the FeignClient of Service B in Service A
#FeignClient(name = "serviceb")
public interface ServiceBClient {
#GetMapping("/getmessage/")
public Inventory getInventoryDetails();
}
I believe one of the primary reasons we use a gateway is to allow the service A to send request to Gateway instead of directly using the service name.
But it seems with feign client the purpose is destroyed.
How to send request to Gateway using feign client?
if you want to give the URL of API-gateway, you can provide it instead of the service name. then the request doesn't go to the related service and, the request goes to the API gateway and, the API gateway will route the request to the relevant service. then the API gateway will be busy for nothing. because, if you gave the service name, the request directly goes to the request by using the cached services IP address data. due to the internal request, the request doesn't want to go through the security filters as well.
#FeignClient(url = "http://localhost:8081/order-service")
I have below the requirement to be implemented in Spring Boot.
How to achieve this?
Consume a message from a topic and Transform the message fields for the REST API
POST it to a REST API via HTTP or HTTPs.
Capture the API response.
Record any errors while posting the message.
You can use Spring Kafka or Spring Cloud Stream with Kafka binder to receive the message.
It will deserialize it you, then you can transfrom it to object you want.
Then you can use (inject) RestTemplate (or Webclient for reactive) to post the message. It will send the message and receive the response. For error handling, you can use the default ones via try/catch, or implement your own by implementing ResponseErrorHandler .
Some useful links:
RestTemplate
RestTemplate Error handling
Spring Kafka
I do not want to use feign or rest template.
My scenario is:
i need to get the JWT token from auth service then pass it to the order cancellation service. I do not want that user add the returned token rather i want to get the token in api gateway and then call other services
I am using Spring integration WS 2.2 outbound gateway to invoke a webservice.
One of our requirement is to capture the soap request and response xmls to the database in addition to some other values like transaction id etc.
If i use ClientInterceptor to save the request/response to DB, it only has access to the soap request and the response but not to the values like transaction Id. So is there a way to retrieve and return the soap request and response from the interceptor OR a way to pass custom values to the interceptor?
Thanks