开发学院软件开发Java 关于在weblogic中异步调用webservice 阅读

关于在weblogic中异步调用webservice

 2009-09-22 00:00:00 来源:WEB开发网   
核心提示: 请求发送完了,交给服务器去执行,关于在weblogic中异步调用webservice(4),下面我们再来看看客户端是如何处理response的,weblogic.webservice. core.ClientDispatcher.asyncDispatch()中,如果请求依然没有结束,则由客户端

请求发送完了,交给服务器去执行,下面我们再来看看客户端是如何处理response的。weblogic.webservice. core.ClientDispatcher.asyncDispatch()中,请求发送结束后,weblogic将启用一个新线程来接受服务器的 response,如下:

1       getThreadPool().addTask(new Runnable() {
2         public void run() {
3           callReceive(messageContext);
4         }
5       });

注意:这个线程是在客户端启动的。该接收线程启动后,FutureResultImpl实例会返回给客户端,客户端由此可以继续他的业务逻辑,而不必block在等待response上。response由接收线程负责处理,收到response,处理后的结果会被植入 FutureResultImpl,客户端执行它的其他逻辑,需要处理处理该结果时,只需要检查请求是否处理结束,如果结束,处理请求结果,如果请求依然没有结束,则由客户端决定继续等待,还是放弃(主线程退出),如下:

1 //you other business logic here
2 if(result.isCompleted())
3 {
4     String ret = port.endSayHello(result);
5     System.out.println(ret);
6  }

客户端接受流程:

weblogic.webservice.core.ClientDispatcher.asyncDispatch(final Object[] args, final AsyncInfo async)
====>
weblogic.webservice.core.ClientDispatcher.callReceive(WLMessageContext ctx)
//call receive() here, and if response was received, set it to FutureResultImpl that owned by the client and if Listener is configured, trigger the listner.

1       if (listener != null) {
2         InvokeCompletedEvent event = new InvokeCompletedEvent(
3             async.getCaller());
4 
5         event.setFutureResult(futureResult);
6         listener.onCompletion(event);
7       }

====>
weblogic.webservice.core.ClientDispatcher.receive(WLMessageContext ctx)
//resoponse is handled by a handler chain
====>
weblogic.webservice.core.handler.ClientHandler.handleResponse(MessageContext ctx)
====>
weblogic.webservice.binding.http11.Http11ClientBinding.receive( MessageContext context )
//read response from the input stream of connect that we send request with, and the thread will be blocked in 
//waiting data from server.

上一页  1 2 3 4 5  下一页

Tags:关于 weblogic 异步

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接