设为首页 收藏本站
查看: 713|回复: 0

[经验分享] Protocol-Based Correlation in WF 4.0---Context Exchange Correclation

[复制链接]

尚未签到

发表于 2015-9-11 10:05:25 | 显示全部楼层 |阅读模式
http://msdn.microsoft.com/en-us/library/ee358724.aspx

  Question:does anyone know the  Context Exchange Correclation topic in msdn ? in this article . it took me a whole afternoon to read and test the code example , actually ,it always seems to be enough simple. but , finally . i have to say . i am fail and confused with this article . it drived me nuts. following exactly the steps with the article provides. writing the code . and debugging , testing .... it doesn't work . all this thing make me believe . maybe it is a bug of msdn ? DSC0000.gif
  and the worst  of all is you can not find the example in which is attached with . that is known as the NetContextExchangeCorrelation sample.
  
  
fortunately, i found another good article which has the same topic . from here.  
  As a tester for correlation, I am sometimes asked to debug projects where people can’t get content-based correlation working. One of the common things that I like to ask is “Why are you using Content-based correlation”? Most of the time I’m met with a blank stare, or maybe the response “because that’s how this works, right Darren?”
  Content-based correlation isn’t the only form of correlation in WF 4.0, and in fact it’s definitely the more complex of the two major forms of correlation that we ship with. The other is Context Based Correlation. Like its content based brother, context correlation uses a piece of data in the message (a well known message header) to identify a message and correlate it to a specific instance of a workflow. Unlike Content correlation though, you don’t have to provide any message queries and in most cases you don’t even need to provide a correlation handle.
  Before I go into how Context Correlation works, let’s talk about the pros and cons. The idea with context correlation is that we are removing all of the work of setting up the correlation for you. Anytime that you are adding an ID to your message just for correlation purposes, you can probably just use context correlation and get the same results. Context correlation will not only set up the queries for you, but it will also generate unique data for each of your workflows, and it will store that data for you, meaning you can think about more complex problems, like what’s for lunch.
  Of course context correlation isn’t silver bullet, and in some situations it’s not possible to accomplish your task with context alone. First of all, if you don’t have complete control over what binding will be used, you won’t be able to use context correlation. In order to enable it you need to add a ContextBindingElement, if you can’t add that your binding, then you are going to need to use Content correlation. There is one other difference as well, a context correlation is always going to tie one client workflow with one service workflow, if you want to go beyond that then you need to go through alot of effort to grab the context from the channel, and most likely you would be better off with content based correlation. Because of the fact that there is just a tight coupling between the client/service once your client or service workflow completes the correlation is effectively terminated. Content correlation on the other hand is independent on the client, so you can have multiple client workflows, or maybe the same client workflow that connects multiple times. The point is that with context correlation you usually pair one client side workflow with one service side workflow, if that’s your situation, then great otherwise you should to stick with a content-based correlation.
  So, how does Context correlation work? I’ve attached an example workflow which uses context correlation. The workflow starts when a request for a new game is created (the workflow models a typical number guessing game). Anyways the first 3 message are below, the things to note are that the context exchange mechanism requires a request-reply (2-way) operation in order to initiate. Its fairly obvious why when you see how the exchange happens:
  
  Initial Request which activates the service workflow
  <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
    <s:Header>
      <a:Action s:mustUnderstand="1">http://tempuri.org/GuessingGameService/StartNewGame</a:Action>
      <a:MessageID>urn:uuid:3bad75b4-5852-4473-8a9f-326899613804</a:MessageID>
      <a:ReplyTo>
        <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
      </a:ReplyTo>
      <a:To s:mustUnderstand="1">http://localhost:42708/GuessingGameService.xamlx</a:To>
    </s:Header>
    <s:Body>
      <StartNewGame xmlns="http://tempuri.org/">
        <maxNumber>100</maxNumber>
      </StartNewGame>
    </s:Body>
  </s:Envelope>
  
  Response to activating request, send back the context ID
  <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
    <s:Header>
      <a:Action s:mustUnderstand="1">http://tempuri.org/GuessingGameService/StartNewGameResponse</a:Action>
      <a:RelatesTo>urn:uuid:3bad75b4-5852-4473-8a9f-326899613804</a:RelatesTo>
      <Context xmlns="http://schemas.microsoft.com/ws/2006/05/context">
        <Property name="instanceId">52e6ca00-a33b-40b0-8ea3-8df9433ae894</Property>
      </Context>
     </s:Header>
    <s:Body>
      <StartNewGameResponse xmlns="http://tempuri.org/">
        <ActualNumber>14</ActualNumber>
      </StartNewGameResponse>
    </s:Body>
  </s:Envelope>
  
  
  Followup request which contains the context ID..
  
  <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
    <s:Header>
      <a:Action s:mustUnderstand="1">http://tempuri.org/GuessingGameService/MakeGuess</a:Action>
      <a:MessageID>urn:uuid:f1e8d7bf-bb30-491d-aa52-8c06df2dc3f7</a:MessageID>
      <a:ReplyTo>
        <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
      </a:ReplyTo>
      <Context xmlns="http://schemas.microsoft.com/ws/2006/05/context">
        <Property name="instanceId">52e6ca00-a33b-40b0-8ea3-8df9433ae894</Property>
      </Context>
      <a:To s:mustUnderstand="1">http://localhost:42708/GuessingGameService.xamlx</a:To>
    </s:Header>
    <s:Body>
      <MakeGuess xmlns="http://tempuri.org/">
        <PlayerGuess>50</PlayerGuess>
      </MakeGuess>
    </s:Body>
  </s:Envelope>
  
   Well, thanks for reading this. Look for more posts in the near future around correlation, and workflow services!
test project download here
  

  the service is simple enough which includes multiple pairs of receive and sendreply activity. you can not find any correlation setting info with it . and also the client is simple coding . just use a CorrectionScope to wrap all the thing for calling the service which includes multiple pairs of send and receivereply activitiy.
the important point i want to mention here . it both client and service should bind the endpoint using WSHttpContextBinding.
  
anyone who also had the same problem which i mentioned firstly in this article .pls give me some comments or solution .  i will be appreciated for it .  
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-112205-1-1.html 上篇帖子: Enable Exchange Trace(转) 下篇帖子: HDU-1903 Exchange Rates
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表