I am running a test from job which makes a http POST submission to 3rd party REST endpoint and implemented retry using requestHandlerAdvice with backoffpolicy policy set as exponential. I was thinking is there a way to implement circuitBreaker with requestHandlerAdvice . The reason for this is if after couple of retries message fails , then circuit shall remain open and after some threshold when I retry with post request and I get a response, I will resume Post submissions to 3rd party REST endpoint
The framework provides both retry and circuit breaker advices.
Simply add both to the request handler advice chain.
Related
We have one rest API, when we call it. It makes another third party rest API call.
So if third part gives failed response,
then we need to retry based on configuration count and if the error code matches with configured error code in yml.
I am thinking to use normal while loop to make retry and check if retry count and error code matches then retry.
Is this correct way? Does it impact the performance?
Thanks,
Ashwini
The premise is pretty simple.
The usual application flow is as follows:
API Gateway receives a request.
API Gateway triggers Lambda Function with parameters.
Lambda Function runs the logic.
The Lambda Function's response is automatically forwarded to API Gateway as the response to step 1 (Response to the Received API Request).
Here's the issue I'm having. I need to run two functions before returning the response to the received API request. I need the return statement from the second function in step 4 to be the response sent back
to the client.
Now there are more examples where this is necessary. In the future, we might need to run a few services (such as lambda > Lambda > PostgreSQL > API Response) before responding to the request.
Is there a way to receive a request from a client, then run a host of tasks, assemble the necessary data, then use this data as a response in the original API request? So far step-functions seemed a likely solution but I don't know if it can do this.
Until recently this would've been a pain with Step Functions but around re:invent time last year they announced the ability to orchestrate synchronous express workflows: https://aws.amazon.com/blogs/compute/new-synchronous-express-workflows-for-aws-step-functions/
IMO, this would be the best / easiest way to implement what you're looking for.
Currently all the Fulfilment requests originating from api.ai are, POST requests to the base url configured in api.ai Fulfilment section. But to be able to have proper routing (microservice style) set-up on the server side it would be more worthwhile to append the action in the POST URL.
For a substantially large project, there can be hundreds of fulfilment actions and managing all of them in single monolithic project is cumbersome. If the action comes in the URL, then we can configure and organise the actions into multiple cloudfunctions in case of firebase hosting / server side microservices.
Edit:
As answered by matthewayne, I can use my own proxy set-up to route the requests to achieve the goal. But I don't want to introduce any additional delay into the request processing. Because I am expecting huge number of webhooks being fired. This would be a very easy implementation for Google api.ai team to incorporate that allows for a greater flexibility! Hence expecting an answer from google team!
Currently this isn't possible with API.AI's webhook design. I'd recommend setting up a proxy service that unpacks the webhook requests from API.AI, inspects the action and sends the proper request to the proper microservice endpoint and then forwards the response back to API.AI once the microservice has returned its result:
Hi I am working with Web Api 2, is their any way I can handle request and response before reaching to the API controller.
You may be looking for a DelegatingHandler. These are HTTP Message Handlers that can process the request before it reaches the Controller and can also process the response on the way out of the pipeline. Delegating Handlers can also return the response themselves without calling the rest of the pipeline. You can read about Delegating Handlers here.
I am using the new feature Message store and processor from ESB 4 for the reliable delivery.
The endpoint service requires basic auth (a http Authorization header) which I added during the in sequence through a property with scope of "transport".
the endpoint is defined as:
-1
1.0
It works when end point up running, the message will be sent with auth header from in sequence.
when the end point is down, the message will be saved to JMS message store.
The problem is when the message being retried by the ScheduleMessageForwardingProcessor, I don't know where/how to add the auth header, and without the auth header all the retry message will fail even when the endpoint is up again.
Your help will be highly appreciated.
Currently this is a limitation in WSO2 ESB Message Processors. We have added these features in the trunk ESB and they will be available in the next public release of WSO2 ESB.