正 文

实现动态 BPEL 流程


www.7dspace.com  更新日期:2006-1-15 2:12:46  七度空间


  调用多个动态流程。 在某些情况下,可能需要将单个数据集按顺序或并行传递给多个子流程。您可以使用一个或多个 while 循环实现此类行为。

  我们来看一个简单的示例。贷款服务提供商的办公时间可能是按一周的日期安排的。该信息存储在数据库中。贷款请求于星期一到达,当查询数据库时,它返回一个可用贷款服务提供商(United 和 Star)列表。要处理此贷款,需要按顺序或并行调用 United 和 Star 子流程。数据库查询返回以下结果:

<dbOutput>
<part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="response-
headers">null</part>
<part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="DynamiclinksCollection">
<n:DynamiclinksCollection
xmlns:n=http://xmlns.oracle.com/pcbpel/adapter/db/top/MyDynamicLink
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Dynamiclinks>
<address>http://localhost:9700/orabpel/default/UnitedLoan</address>
<day>monday</day>
<uid>1</uid>
</Dynamiclinks>
<Dynamiclinks>
<address>http://localhost:9700/orabpel/default/StarLoan</address>
<day>united</day>
<uid>4</uid>
</Dynamiclinks>
</n:DynamiclinksCollection>
</part>
</dbOutput>

  为了按顺序调用这些服务,您应创建一个 while 循环。该 while 循环从集合中获得地址并对每个服务执行一个动态调用/接收。

<!-- first setup the counter variable "i" -->
<assign name="CounterReset">
<copy>
<from expression="1"/>
<to variable="i"/>
</copy>
</assign>

<!-- while loop goes until all link collection notes are done -->
<while name="LoanLoop" condition="bpws:getVariableData('i') <=
count(bpws:getVariableData('dbOutput','DynamiclinksCollection',
'/ns3:Dynamiclin ksCollection/Dynamiclinks'))">
<sequence name="Sequence_1">

<!-- reset the endpoint with the usual xml fragment -->
<assign name="ClearEndpoint">
<copy>
<from>
<EndpointReference
xmlns="http://schemas.xmlsoap.org/ws/2003/03/addressing"
xmlns:ns1="http://services.otn.com">
<Address/>
</EndpointReference>
</from>
<to variable="partnerReference"/>
</copy>
</assign>

<!-- set the address in the endpoint variable
 based on the current node -->
<assign name="SetEndpoint">
<copy>
<from variable="dbOutput" part="DynamiclinksCollection"
       query="/ns3:DynamiclinksCollection/Dynamiclinks
[number(bpws:getVariableData('i'))]/address"/>
<to variable="partnerReference"
query="/wsa:EndpointReference/wsa:Address"/>
</copy>
</assign>

<!-- copy the endpoint variable into the partner link -->
<assign name="DoPartnerlink">
<copy>
<from variable="partnerReference"/>
<to partnerLink="LoanService"/>
</copy>
</assign>
<!-- invoke the partner link -->
<invoke name="Invoke_2" partnerLink="LoanService"
portType="ns2:LoanService" operation="initiate"
inputVariable="loanInput"/>

<!-- be sure to increment your counter or you have an infinite loop -->
<assign name="CounterIncrement">
<copy>
<from expression="bpws:getVariableData('i')+1"/>
<to variable="i"/>
</copy>
</assign>
</sequence>
</while>

      在以上示例中,您调用了异步服务。但可以并行调用这些异步服务,方法是从 <invoke> while 循环中删除 <receive> 并为它提供一个自己的 while 循环。在运行 <receive> 捕获每个调出流程的响应之前,这些响应将排队。receive 任务将按照响应的返回顺序收集这些响应。该方法将避免短时间运行的任务发出的响应排在长时间运行的任务发出的响应之后。

      在收集了所有异步响应之前,建议不要在 <receive> while 循环外部继续运行。

  结论

  您在本文已经了解到,通过使用端点引用进行动态绑定,BPEL 流程可以变得更为灵活并快速适应不断变化的业务条件。通过将业务逻辑与合作伙伴地址分离,可以增强流程的自适应性和可移植性。

7页,页码:[1] [2] [3] [4] [5] [6] [7] 

上一篇:SOA 重用工程
下一篇:ADO.NET连接池超时
标题:实现动态 BPEL 流程 作者: 来源:Oracle
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐