【问题标题】:Sub-Flow with reuse and concurrency具有重用和并发性的子流
【发布时间】:2013-01-18 16:57:26
【问题描述】:

我正在为我的一个用例准备解决方案。 我的解决方案可能看起来像这样抽象。

我的问题是,当两个主要流程同时调用同一个子流程时, 它会毫无问题地工作吗?

我还需要为所有用作线程安全的类编写代码吗? 子流程中的自定义组件/转换器?

我的抽象配置如下所示。

<flow name="mainflow_1" >
    <inbound-endpoint/>
    <transformer ....>
    <component ....>
        <flow-ref name="subflow_1"></flow-ref>
    <transformer ....>
    <component  ...>
    <outbound-endpoint ....>
</flow>

<flow name="mainflow_2" >
    <inbound-endpoint  type="request-response" />
    <transformer ....>
    <component ....>
        <flow-ref name="subflow_1"></flow-ref>
    <transformer ....>
    <component  ...>            
</flow>

<sub-flow name="subflow_1" >        
    <transformer ....>
    <component ....>
        <outbound-endpoint  call to some service >
    <transformer ....>
    <component  ...>        
</sub-flow>

请指导我。

【问题讨论】:

    标签: concurrency mule reusability mule-flow


    【解决方案1】:

    子流程就像一个宏:执行方面,就好像子流程的元素被复制到调用流程中一样。

    因此,调用流的线程行为将决定子流的线程行为。

    无论它们是用于子流程还是主要流程,如果您使用它们的单例实例(常见用例),您应该将组件类编写为线程安全的。如果您使用原型实例(每个请求创建一个实例)或池实例(实例数量有限,线程瓶颈),您的组件类可能是线程不安全的。

    根据经验,尽可能多地争取线程安全的无状态组件类,以免在未来出现潜在的优化问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-08
      • 2016-08-08
      • 1970-01-01
      • 2021-04-24
      • 2021-10-12
      • 1970-01-01
      • 1970-01-01
      • 2016-01-29
      相关资源
      最近更新 更多