​When to use JavaScript in Apigee and what is advantage of this ?

When to use JavaScript in Apigee and what is advantage of this ?

Solved Solved
1 5 1,076
2 ACCEPTED SOLUTIONS

@Govind Verma
You can use javascript for relatively simple interactions with message content, such as modifying or extracting HTTP headers, parameters, or message content, mashups etc, some of which are not possible with a single Assign Message or Extract variables policy.The primary advantage is the flexibility of writing custom logic using the programming language.

Below is what the Apigee docs states

When to use JavaScript
On Apigee Edge, there is usually more than one way to implement specific functionality. Use out-of-the-box policies where possible, and avoid the temptation to code all of your API proxy logic in JavaScript. Even though Apigee Edge leverages compiled JavaScript to improve performance, it is unlikely that JavaScript will perform as well as Policies. JavaScript may be more difficult to maintain and debug. Reserve JavaScript for functionality that is unique to your requirements.
If performance is a concern for custom functionality, use Java where possible.

View solution in original post

Well, there's two places where JavaScript are use:

  • Policies (declarative API management)
  • Node.js (Trireme and Hosted Targets, custom API management/orchestration)

Ultimately, when to use JavaScript in general is whenever you want to do something Edge doesn't support (custom policies, custom API management/orchestration) or when you would rather do things programmatically instead of declaratively. But as @Nagashree B said, this can have some performance impact. But in some cases, there is no way to do what you need and there is no better way to do what you seek without custom JavaScript that does what you need.

View solution in original post

5 REPLIES 5

@Govind Verma
You can use javascript for relatively simple interactions with message content, such as modifying or extracting HTTP headers, parameters, or message content, mashups etc, some of which are not possible with a single Assign Message or Extract variables policy.The primary advantage is the flexibility of writing custom logic using the programming language.

Below is what the Apigee docs states

When to use JavaScript
On Apigee Edge, there is usually more than one way to implement specific functionality. Use out-of-the-box policies where possible, and avoid the temptation to code all of your API proxy logic in JavaScript. Even though Apigee Edge leverages compiled JavaScript to improve performance, it is unlikely that JavaScript will perform as well as Policies. JavaScript may be more difficult to maintain and debug. Reserve JavaScript for functionality that is unique to your requirements.
If performance is a concern for custom functionality, use Java where possible.

Thanks for your reply Nagashree B

Well, there's two places where JavaScript are use:

  • Policies (declarative API management)
  • Node.js (Trireme and Hosted Targets, custom API management/orchestration)

Ultimately, when to use JavaScript in general is whenever you want to do something Edge doesn't support (custom policies, custom API management/orchestration) or when you would rather do things programmatically instead of declaratively. But as @Nagashree B said, this can have some performance impact. But in some cases, there is no way to do what you need and there is no better way to do what you seek without custom JavaScript that does what you need.

Thanks for your reply @Jeremy Whitlock

Thank you for such an informative thread! I am just at the stage of forming an idea for an IT project. According to the bitter experience of the past, I have not yet decided in what language we will write it. But fortunately, I have already found a good development team.
I gathered the cool guys on https://ithire.com/category/javascript-developers. A very convenient website with good specialists. I advise everyone.
But still, I don't know whether to give preference to new models or old ones. Maybe someone will give advice?