Is Java Callout class threadsafe

nsaini
New Member

Is Java Callout class threadsafe. My java class takes an array and encrypts each element and returns encrypted element array. ANother java callout is for SOAP message signing.

Solved Solved
0 2 507
1 ACCEPTED SOLUTION

In Apigee Edge, a Java callout will be invoked by multiple threads concurrently.

It is thread safe if you make it thread safe!

Let's take a step back:

A Java callout is code that YOU write. So if you write it in such a way that it handles multiple threads safely, it is thread-safe. If you write it in such a way that it does not handle that condition, then it will not be thread safe.

In general, there will be one or more instances of the Java callout class created. In general each of those instances will be called by more than one thread at a time. The execute() method should not write static or class-specific state. If the execute() method writes state (for example a cache), it should use appropriate thread locking or should use frameworks or libraries that are thread safe.

Clear?

View solution in original post

2 REPLIES 2

In Apigee Edge, a Java callout will be invoked by multiple threads concurrently.

It is thread safe if you make it thread safe!

Let's take a step back:

A Java callout is code that YOU write. So if you write it in such a way that it handles multiple threads safely, it is thread-safe. If you write it in such a way that it does not handle that condition, then it will not be thread safe.

In general, there will be one or more instances of the Java callout class created. In general each of those instances will be called by more than one thread at a time. The execute() method should not write static or class-specific state. If the execute() method writes state (for example a cache), it should use appropriate thread locking or should use frameworks or libraries that are thread safe.

Clear?

Yes. Thanks @Dino for prompt and detailed reply.