如何并行调用3个REST端点?

时间:2022-11-17 13:48:29

I have to invoke REST endpoints A, B & C in parallel and combine the resulting JSON from each into one JSON. All REST endpoints reside on different servers.

我必须并行调用REST端点A,B和C,并将每个端点的JSON组合成一个JSON。所有REST端点都驻留在不同的服务器上。

My initial design calls for 3 Callables executed via FutureTasks. I will then do a Future.get(1000ms) on each FutureTask until they return a value. Is this how you would solve this problem ?

我的初始设计要求通过FutureTasks执行3个Callables。然后,我将在每个FutureTask上执行Future.get(1000ms),直到它们返回一个值。这是你怎么解决这个问题的?

1 个解决方案

#1


That's how I would do it. I really like the Future interface.

我就是这样做的。我非常喜欢Future界面。

#1


That's how I would do it. I really like the Future interface.

我就是这样做的。我非常喜欢Future界面。