Multiple target endpoints in parallel

My goal is to call 2 endpoints in parallel, and aggregage the data into a single response.

I was able to do it in a NodeJS plugin. However I don't find a way to create a "No Target" microgateway (since my API calls are done in my plugin) Is there a way to do it? Or maybe there is an other way to do multiple parallel APIs calls within a Target?

Solved Solved
0 1 1,193
1 ACCEPTED SOLUTION

Hi Maxime,

There is currently no way to do either of these things. Edge Microgateway expects that there is exactly one and only one target endpoint for each microgateway enabled proxy in Apigee Edge. The custom plugin would be the best solution to achieve the service mashup pattern, as it is the equivalent of using a Service Callout policy for standard Edge proxies.

Since having a 'no target' Edge microgateway proxy is not possible, one workaround would be to use a target running on the same server that doesn't do anything. I.e. Create a 'edgemicro_nulltarget' proxy that has a target endpoint url of http://localhost:8080/dev/null. Of course, it would have to return a HTTP 2xx status code, so you would need to run a http server on each host where mgw runs. You could then place your custom plugin in the 'onend_response' handler and override the response that goes back to the client.

The cleaner alternative would be to implement a custom backend microservice which does both calls, the aggregation, and then your mgw proxy would just call that. You could run this inside a docker container or on GKE cluster on your data center.

Mark

View solution in original post

1 REPLY 1

Hi Maxime,

There is currently no way to do either of these things. Edge Microgateway expects that there is exactly one and only one target endpoint for each microgateway enabled proxy in Apigee Edge. The custom plugin would be the best solution to achieve the service mashup pattern, as it is the equivalent of using a Service Callout policy for standard Edge proxies.

Since having a 'no target' Edge microgateway proxy is not possible, one workaround would be to use a target running on the same server that doesn't do anything. I.e. Create a 'edgemicro_nulltarget' proxy that has a target endpoint url of http://localhost:8080/dev/null. Of course, it would have to return a HTTP 2xx status code, so you would need to run a http server on each host where mgw runs. You could then place your custom plugin in the 'onend_response' handler and override the response that goes back to the client.

The cleaner alternative would be to implement a custom backend microservice which does both calls, the aggregation, and then your mgw proxy would just call that. You could run this inside a docker container or on GKE cluster on your data center.

Mark