使用Executor框架在Weblogic SOAP Webservice中创建后台线程 [英] Background thread creation in Weblogic SOAP Webservice using Executor framework

查看:208
本文介绍了使用Executor框架在Weblogic SOAP Webservice中创建后台线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Weblogic服务器上部署了一个SOAP Web服务,其流程如下所示。

We have a SOAP webservice deployed on Weblogic server with the flow as follows.


SOAP客户端将向Webservice发送消息,验证消息并发送确认作为服务的响应。但是,假设在后台执行SocketConnection以进一步异步处理消息。

SOAP Client will send message to Webservice which validates the message and sends an Acknowledgement as response of the service. However, it is suppose to do a SocketConnection in the background to further process the message as asynchronously.

已提供的实现是使用 ExecutorService.newFixedThreadPool 在后台生成ChildThread。这是正在使用的代码(并非所有web服务实现文件的代码都在这里发布)。

The implementation that has been provided is to spawn a ChildThread in the background using ExecutorService.newFixedThreadPool. this is the code being used (not all the code for the webservice implementation file is posted here).

  if ("103".equals(requestType)) {
    ExecutorService executorService = Executors.newFixedThreadPool(1);
    executorService.submit(new MessageProcessing103(coreMsg, otherDetails));
  } else if ("104".requestType) {
         ExecutorService executorService = Executors.newFixedThreadPool(1);
         executorService.submit(new MessageProcessing104(coreMsg, otherDetails));
    }

使用上述实现可扩展性肯定是一个问题但我们可以忍受它作为现在你可以帮助解决以下问题吗

With the above implementation Scalability is definitely an issue but we can live with it as of now. Can you help with the below queries though


  1. 由于后台线程很长,这意味着同一个衍生线程将用于执行所有请求?

  2. 如果两个请求以几秒钟的间隔进入,第二个请求是否会处于等待状态或者会产生新的线程?

  3. 我们没有关闭执行程序,所以在这种情况下会遇到什么问题?


推荐答案


  1. 对于每个请求,您创建一个仅执行该请求的新线程。

  2. 相同。

  3. 很快就会遇到OutOfMemoryError - 创建并且没有关闭执行程序会占用所有内存。

我的建议不是为每个内存创建新的执行程序请求,但重用相同的执行程序。让那个执行器包含几个线程。不是一个。

My advice is not to create new executor for each request, but reuse the same executor. And let that executor contain several threads. not one.

这篇关于使用Executor框架在Weblogic SOAP Webservice中创建后台线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆