Java callout policy to initiate and cache connections to external hosts

Not applicable

I went through some of the posts in which it is mentioned that Java callout policy could initiate connections to external hosts.

My question is whether Apigee also provisions to cache those connections e.g. since Apigee platform is in cloud and I have cached connections in Java callout code, however the requests may not always go to that instance and may go to different instances in which case the Java callout would not find the connections cached in one instance. Is my understanding correct?

1 2 198
2 REPLIES 2

yes, your understanding is correct.

If you create and maintain a cache or pool of connections, that cache or pool will be local to the instance of the callout.

There will be a single Java callout instantiated per { ORG / ENV / APIProxy / Revision } tuple, for each message processor. If you have 3 MPs, and your callout is used in a single Proxy, which is deployed to a single environment, then you will get 3 instances of the callout, each in a different process on a different virtual machine.

If you use the callout in a 2nd API Proxy, then you will get 6 instances, though only 3 distinct processes. If you deploy those 2 proxies into a second environment, then you will get 12 instances, still in 3 distinct Java processes on three distinct machines. If the environments both auto-scale to 5 MPs, then you will get ( 5 * 2 * 2 ) = 20 instances of the callout, in 5 distinct processes.

Former Community Member
Not applicable

Great answer!

What happens if the Java callout is part of a global shared flow, i.e. called from a flow hook?

Will the java class instance be similarly scoped to the { ORG / ENV / APIProxy / Revision } tuple or will it be scoped to { org, env, hook, flow_revision }?