Oracle Service Bus中的线程

jib以前在给客户讲产品的时候经常提到Oracle Service Bus服务总线适合于短连接,高频率的交易,而不适合那些大报文,然后花费很长的调用时间的应用,前一阵在给客户培训完企业服务总线后,又对OSB的限流机制有了一定了解,事实上,自己的理解也有很多偏差,下面就把在国外看到的一片讲Oracle Service Bus线程机制的文章和大家分享一下吧。

企业服务总线的典型场景

 如果我们把pipeline中间的逻辑拉直的话,我们可以看到基本是这个图:

  • Request Pipeline:在接收的pipeline中收到请求做处理
  • RouteNode:通过路由节点调用业务服务
  • Response Pipeline: 处理业务服务的回应,然后将结果返回.(这个图是个特例,具体是判断结果,修改请求,在去调用一个业务服务,然后回送回应)

基本模型

  • 在请求pipeline中Oracle Service Bus会启用一个线程(Thread)
  • 在调用业务服务的时候,线程释放,回到线程池,同时一个muxer等待回应
  • 当回应收到,muxer把接收到的新的请求发送给一个新的线程,并执行response pipeline.

所以

我们可以为Proxy Service和Business Service定义不同的线程池,也就是Proxy Service WorkManager和Business Service WorkManager

没有包含路由节点

如果没有路由节点,OSB仍然会采用另外一个thread处理响应pipeline,但是采用的Default Work Manager

代理服务调用代理服务

 同一线程调用Proxy Service的请求Pipeline,同一线程调用Response Pipeline

服务外调

 Pipeline处理会block线程直到响应能够异步返回。在进行服务外调的时候,原来的线程不会释放,muxer使用Business Service Work Manager分配一个线程来处理请求,如果大家共享一个work manager,比较容易造成死锁。

总结

  • Request Pipeline
    • Executes on Proxy Work Manager (WM) Thread so limited by setting of that WM.  If no WM specified then uses WLS default WM.
  • Route Node
    • Request sent using Proxy WM Thread
    • Proxy WM Thread is released before getting response
    • Muxer is used to handle response
    • Muxer hands off response to Business Service (BS) WM
  • Response Pipeline
    • Executes on Routed Business Service WM Thread so limited by setting of that WM.  If no WM specified then uses WLS default WM.
  • No Route Node (Echo functionality)
    • Proxy WM thread released
    • New thread from the default WM used for response pipeline
  • Service Callout
    • Request sent using proxy pipeline thread
    • Proxy thread is suspended (not released) until the response comes back
    • Notification of response handled by BS WM thread so limited by setting of that WM.  If no WM specified then uses WLS default WM.
      • Note this is a very short lived use of the thread
    • After notification by callout BS WM thread that thread is released and execution continues on the original pipeline thread.
  • Route/Callout to Proxy Service
    • Request Pipeline of callee executes on requestor thread
    • Response Pipeline of caller executes on response thread of requested proxy
  • Throttling
    • Request message may be queued if limit reached.
    • Requesting thread is released (route node) or suspended (callout)
原文地址:https://www.cnblogs.com/ericnie/p/6625886.html