Hello All,
Here is my use case.
I want to make a concurrent/parallel call to two different target server in Apigee proxy and send results back to client. There will be responses from only one target server at a time.
I read in one apigee forum which suggests to use node js policy and use async module to make the parallel call to different target server.
I just want to know, is there any alternatives? Any built-in policy in Apigee to support this use case. Which is the best way to achieve it?
Thanks,
Mohan
Resource callouts will be your best bet here - Python, Java, or perhaps Javascript.
Alternatively you can create Google Cloud Function - or similar - to do the same and have Apigee call that function.
Keep in mind your security requirements in this choice.
@Mohan Dev Thazhathethil , Any reason you are looking for alternative ? Why not Node.JS which gets job done ?
@Anil Sagar Hello Anil, I just want to know any alternative options available for this? What is your suggestion
@Mohan Dev Thazhathethil - will recommend using NodeJS
I have used javascript in past as an alternative to node and works like a charm. More details can be found here - https://community.apigee.com/articles/2340/asynchronous-http-requests-in-an-api-proxy.html
+1 Node.js excels at this. And you can do it in just a few lines of code. As you mentioned async module works okay. If you like Promises there's an example for it too here https://github.com/dzuluaga/apigee-tutorials/tree/master/apiproxies/nodejs-request-promise-api.
var express = require('express') app = express(), request = require('request'), url = require('url'), promise = require('bluebird'), // you'll need bluebird or other module to convert callbacks to promises request = promise.promisify(require('request')); // promisify the request module app.get('/*', function (req, res) { var query = url.parse(req.url).query; //get query params from url request('http://lyrics.wikia.com/api.php?' + query) // use promisified request module .then(function (response) { //this is way clean than using callbacks! res.json(JSON.parse(response.body)); }) .catch(function (err) { res.send(err); }) })
I have the same requirement to call two different target URLs for same condition.i mean parallel call to different endpoints always. can someone explain how JS used here
I have the same requirement to call two different target URLs for same condition.i mean parallel call to different endpoints always. can someone explain how JS used here