简体   繁体   English

在Java EE应用程序中同时进行httpurlconnection调用的最佳方法是什么

[英]What is the best way to make simultaneous httpurlconnection calls in a Java EE application

We have a requirement where we have to make four web service calls from our EJB. 我们有一个要求,我们必须从EJB进行四个Web服务调用。 All these calls are independent of each other and should be made simultaneously. 所有这些调用是相互独立的,应该同时进行。

Today we are using ExecutorService to make these calls. 今天,我们正在使用ExecutorService进行这些调用。 There is a timeout after which we shutdown the ExecutorService and check the responses. 超时后,我们将关闭ExecutorService并检查响应。

I want to know if there is a better way to do the same? 我想知道是否有更好的方法可以做到这一点?

PS We use websphere 8.5.0 which is a Java EE 6 server. PS我们使用Websphere 8.5.0,它是Java EE 6服务器。 I found there is ManagedExecutorService in Java EE 7. Is there anything in Java EE 6? 我发现Java EE 7中有ManagedExecutorService。JavaEE 6中有什么吗?

Have you considered using an asynchronous method on a Stateless Session Bean (with the @Asynchronous annotation)? 您是否考虑过在无状态会话Bean上使用异步方法(带有@Asynchronous批注)? This method would make the call to the web service and the app server (via the EJB pool) would be responsible for managing concurrency. 此方法将导致对Web服务的调用,并且应用服务器(通过EJB池)将负责管理并发。

See: https://docs.oracle.com/javaee/6/tutorial/doc/gkkqg.html 请参阅: https//docs.oracle.com/javaee/6/tutorial/doc/gkkqg.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM