Message Exchanges, Revisited


As noted earlier, the BPEL engine can pair a reply activity with an inbound message activity, but only if the paired activities reference the same partner link, operation, and message exchange. The pairing allows the BPEL engine to direct the reply appropriately.

In most cases, the process creates a default message exchange for each activity, and you need to specify only the partner link and operation. An explicit message exchange is necessary at times, as in the following example.

In response to most car-insurance policy requests, the BPEL process CheckCredit requires financial data from the applicant and co-applicant. The process includes a receive activity for each applicant in sequence.

 <sequence>    <receive partnerLink="CreditCheck"             operation="checkFamilyCredit"             variable="applicantInfo"             createInstance="yes"             messageExchange="applicant" />    <receive partnerLink="CreditCheck"             operation="checkFamilyCredit"             variable="spouseInfo"             createInstance="no"             messageExchange="spouse" /> </sequence> 

As shown, the two activities are based on the same partner link and operation and are distinguished only by the message-exchange value. The message-exchange values were defined earlier, as follows.

 <messageExchanges>    <messageExchange name="applicant" />    <messageExchange name="spouse" /> </messageExchanges> 

Assume that in the subsequent flow activity, shown in Listing 8.14, a calculation occurs at the same time for each applicant (within the sequence activity that we show for simplicity). We cannot know which calculation will end first, but in any case, a reply is necessary to the appropriate applicant, and the message-exchange value is required so that the BPEL engine can match a receive activity and the subsequent reply.

Listing 8.14: Use of message exchanges

image from book
 <flow>    <links>       <link name="ApplicantLink" />       <link name="SpouseLink" />    </links>    <!- assume that activities in each sequence activity         perform a calculation. The reply statements that follow         the calculation run concurrently, but must respond to a         specific request. ->    <sequence name="Calculate credit report for spouse">       .       .       <sources>          <source linkName="SpouseLink" />       </sources>    </sequence>    <reply partnerLink="CreditCheck"           operation="checkFamilyCredit"           variable="resultSpouse"           messageExchange="spouse">       <targets>          <target linkName="SpouseLink" />       </targets>    </reply>    <sequence name="Calculate credit report for applicant">       .       .       <sources>          <source linkName="ApplicantLink" />       </sources>    </sequence>    <reply partnerLink="CreditCheck"           operation="checkFamilyCredit"           variable="resultApplicant"           messageExchange="applicant">       <targets>          <target linkName="ApplicantLink" />       </targets>    </reply> </flow> 
image from book

In general, you must do as follows if multiple IMA-and-reply pairs reference the same partner link and operation and if those activity pairs may run at the same time:

  • Declare a message exchange for each IMA-and-reply pair.

  • Reference the appropriate message exchange when you define each activity, to make the pairings explicit.




SOA for the Business Developer. Concepts, BPEL, and SCA
SOA for the Business Developer: Concepts, BPEL, and SCA (Business Developers series)
ISBN: 1583470654
EAN: 2147483647
Year: 2004
Pages: 157
Authors: Ben Margolis

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net