<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Routing Rules!</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/routingrules/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/routingrules/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:26:40 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>RIA Services + Routing</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/ria-services-routing</link>
      <pubDate>Tue, 24 Aug 2010 08:49:30 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2010/08/24/ria-services-routing/</guid>
      <description><![CDATA[Yavor Georgiev does an amazing witeup of how to get the Routing Services working for RIA...]]></description>
      <content:encoded><![CDATA[<p>Yavor Georgiev does an amazing witeup of how to get the Routing Services working for RIA services.&nbsp; This took some consultation, but I'm glad to report we have things working :)&nbsp; You can find his blog post and the sample project over <a target="_blank" href="http://hashtagfail.com/post/1000967093/wcf-routing-ria-services">here</a>.</p>]]></content:encoded>
    </item>
    <item>
      <title>ServiceModel XPath Functions</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/servicemodel-xpath-functions</link>
      <pubDate>Tue, 04 May 2010 16:54:25 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2010/05/04/servicemodel-xpath-functions/</guid>
      <description><![CDATA[One of the most versatile types of filters that the Routing Service offers is the...]]></description>
      <content:encoded><![CDATA[<p>One of the most versatile types of filters that the Routing Service offers is the XPathMessageFilter.&#160; Xpath is great because it gives you a full set of navigation and comparison tools, right in one filter.&#160; But let’s be honest, writing XPath by hand kinda stinks.&#160; Fortunately, XPath has the notion of functions (or shortcuts) which can be used as shorthand for longer XPath statements.&#160; As an added benefit, when you use the XPath filter inside the framework, there a whole bunch of functions that are already defined for you.&#160; Here’s the ones I’ve found particularly useful.&#160; To use these, just write them into the XPath filter, prefaced by the sm: namespace declaration.</p>  <table border="0" cellspacing="0" cellpadding="0"><tbody>     <tr>       <td width="301">         <p><b>XPath Shortcut Key</b></p>       </td>        <td width="431">         <p><b>Equivalent Functionality</b></p>       </td>        <td width="1224">         <p><b>Expanded XPath Context String</b></p>       </td>     </tr>      <tr>       <td width="301">         <p>header()</p>       </td>        <td width="431">         <p>Returns a node set containing just the header node.</p>       </td>        <td width="1224">         <p>(/s11:Envelope/s11:Header | /s12:Envelope/s12:Header)</p>       </td>     </tr>      <tr>       <td width="301">         <p>body()</p>       </td>        <td width="431">         <p>Returns a node set containing just the body node.</p>       </td>        <td width="1224">         <p>(/s11:Envelope/s11:Body | /s12:Envelope/s12:Body)</p>       </td>     </tr>      <tr>       <td width="301">         <p>soap-uri()</p>       </td>        <td width="431">         <p>Returns the string value of the soap namespace of the message.</p>       </td>        <td width="1224">         <p>namespace-uri(/s11:Envelope | /s12:Envelope)</p>       </td>     </tr>      <tr>       <td width="301">         <p>headers-with-actor(string)</p>       </td>        <td width="431">         <p>Returns a node set containing all header nodes with the specified role/actor.</p>       </td>        <td width="1224">         <p>/s11:Envelope/s11:Header/*[@s11:actor=$string] | s12:Envelope/s12:Header/*[@s12:role=$string]</p>       </td>     </tr>      <tr>       <td width="301">         <p>actor(node-set)</p>       </td>        <td width="431">         <p>Returns the string value of the role/actor attribute of the first node in the node set.</p>       </td>        <td width="1224">         <p>string($node-set[1][/s11:Envelope]/@s11:actor | $node-set[1][/s12:Envelope]/@s12:role)</p>       </td>     </tr>      <tr>       <td width="301">         <p>is-mandatory(node-set)</p>       </td>        <td width="431">         <p>Returns the Boolean value of the “mustUnderstand” attribute of the first node in the node set.</p>       </td>        <td width="1224">         <p>$node-set[1][/s11:Envelope]/@s11:mustUnderstand=“1” | $node-set[1][/s12:Envelope]/@s12:mustUnderstand=“true”</p>       </td>     </tr>      <tr>       <td width="301">         <p>is-actor-next(node-set)</p>       </td>        <td width="431">         <p>Returns true/false depending on whether the role/actor attribute of the first node in the node set is the “next” value.</p>       </td>        <td width="1224">         <p>(/s11:Envelope and sm:actor($node-set)=“<a href="http://schemas.xmlsoap.org/soap/actor/next">http://schemas.xmlsoap.org/soap/actor/next</a>”) | (/s12:Envelope and sm:actor($node-set)=“<a href="http://www.w3.org/2003/05/soap-envelope/role/next">http://www.w3.org/2003/05/soap-envelope/role/next</a>”)</p>       </td>     </tr>      <tr>       <td width="301">         <p>is-actor-ultimate-receiver(node-set)</p>       </td>        <td width="431">         <p>Returns the true/false depending on whether the role/actor attribute of the first node in the node set is the “ultimate receiver” value.</p>       </td>        <td width="1224">         <p>(/s11:Envelope and sm:actor($node-set)= “”) | (/s12:Envelope and sm:actor($node-set)= “<a href="http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver">http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver</a>”)</p>       </td>     </tr>      <tr>       <td width="301">         <p>messageId()</p>       </td>        <td width="431">         <p>Returns the string value of the ws-Addressing MessageId header (string).</p>       </td>        <td width="1224">         <p>string((sm:header()/wsa:MessageID/text( ))[1])</p>       </td>     </tr>      <tr>       <td width="301">         <p>relatesTo()</p>       </td>        <td width="431">         <p>Returns the ws-Addressing RelatesTo headers (node-set)</p>       </td>        <td width="1224">         <p>sm:header( )/wsa:RelatesTo</p>       </td>     </tr>      <tr>       <td width="301">         <p>replyTo()</p>       </td>        <td width="431">         <p>Returns the ws-Addressing ReplyTo header (node-set)</p>       </td>        <td width="1224">         <p>(sm:header( )/wsa:ReplyTo)[1]</p>       </td>     </tr>      <tr>       <td width="301">         <p>from()</p>       </td>        <td width="431">         <p>Returns the ws-Addressing From header (node-set)</p>       </td>        <td width="1224">         <p>(sm:header( )/wsa:From)[1]</p>       </td>     </tr>      <tr>       <td width="301">         <p>faultTo()</p>       </td>        <td width="431">         <p>Returns the ws-Addressing RelatesTo header (node-set)</p>       </td>        <td width="1224">         <p>(sm:header( )/wsa:FaultTo)[1]</p>       </td>     </tr>      <tr>       <td width="301">         <p>to()</p>       </td>        <td width="431">         <p>Returns the string value of the ws-Addressing To header (string).</p>       </td>        <td width="1224">         <p>string(sm:header( )/wsa:To)</p>       </td>     </tr>      <tr>       <td width="301">         <p>action()</p>       </td>        <td width="431">         <p>Returns string containing the string value of the ws-Addressing Action header (string).</p>       </td>        <td width="1224">         <p>string((sm:header( )/wsa:Action/text())[1])</p>       </td>     </tr>      <tr>       <td width="301">         <p>recipient()</p>       </td>        <td width="431">         <p>Returns the ws-Addressing recipient header (node-set)</p>       </td>        <td width="1224">         <p>(sm:header( )/wsa:Recipient)[1]</p>       </td>     </tr>   </tbody></table>  <p>In a post below, and in several samples, I use sm:header() to quickly navigate to the header collection in order to determine if a particular header is present.&#160; With this data, you can also go ahead and start to write other XPath functions that riff off of these.&#160; Have at it!</p>  <p>&#160;</p>  <p>-Matt</p>]]></content:encoded>
    </item>
    <item>
      <title>Load Balancing at the Routing Service</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/load-balancing-at-the-routing-service</link>
      <pubDate>Tue, 13 Apr 2010 23:04:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2010/04/13/load-balancing-at-the-routing-service/</guid>
      <description><![CDATA[This post subtitled “I hate to tell you this but….”
  “Can the Routing Service do load balancing?”...]]></description>
      <content:encoded><![CDATA[<p><font size="1">This post subtitled “I hate to tell you this but….”</font></p>
  <p>“Can the Routing Service do load balancing?” is one of the most 
common questions I’m asked.&nbsp; The immediate answer I give is almost 
universally disappointing: No.&nbsp; It’s actually hard to say that Load 
Balancing (as most people mean it) <i>should</i> be done at the Routing 
Service.&nbsp; But why?&nbsp; It seems like since I have this intermediary that 
load balancing is one of the obvious applications.&nbsp; Here’s why it 
doesn’t work as well or as easily as it should.</p>  <p>How would I 
build a filter that allowed me to do something simple like Round Robin 
load balancing?&nbsp; Well, it would seem that I would have a filter, one for
 each destination that I wanted to send to, and as each message came 
through, only one of the selected filters would respond that it 
matched.&nbsp; So a setup like this:</p>  <p>RoundRobinFilter1 –&gt; 
Endpoint1</p>  <p>Round RobinFilter2 –&gt; Endpoint2</p>  <p>RoundRobinFilter3
 –&gt; Endpoint3 </p>  <p>Which we then fed 3 messages would result in 
message 1 going to Endpoint1, message 2 to Endpoint 2, etc.</p>  <p>But 
building this is hard :) Why?&nbsp; You immediately run into two issues:</p> 
 <ol><li>How do these MessageFilters exchange information?&nbsp; Basically
 how does each filter know that this time it’s the one that needs to 
match (and the other two know that they’re not)?</li><li>How does 
this information stay around between messages?&nbsp; Remember that 
MessageFilters are designed to be stateless, meaning that they don’t 
normally have any information and would always match a given message the
 same way. </li></ol>  <p>We actually have a sample out that shows how 
this would work, but it relies on a “creative” use of the MessageFilter 
API.&nbsp; The hint is that MessageFilters can be a used as a factory to 
create the MessageFilterTable that they belong to.&nbsp; Another key point is
 that MessageFilterTables can contain child MessageFilterTables (usually
 of a specific type).&nbsp; An example of this in the framework today is the 
XPathMessageFilter.&nbsp; When you add a XPathMessageFilter to the Routing 
Service’s MessageFilterTable, that’s actually not what happens.&nbsp; 
Instead, this is the structure you end up with:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFT_2.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFT_2.png" mce_href="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFT_2.png"><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFT_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFT_thumb.png" style="border: 0px none; display: block; float: none; margin-left: auto; margin-right: auto;" title="XPathMFT" alt="XPathMFT" mce_src="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFT_thumb.png" border="0" height="409" width="528"></a> </p>  <p>Where did this middle
 XPathMessageFilterTable come from?&nbsp; Reflector gives us the answer.&nbsp; 
When the XPathMessageFilter is added to the parent MessageFilterTable 
(red), the parent MFT actually calls CreateFilterTable on the 
XPathMessageFilter, at which point the XPathMessageFilter creates a new 
XPathMessageFilterTable and returns it to the parent MessageFilterTable 
to use.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFTCreateFilterTable_2.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFTCreateFilterTable_2.png" mce_href="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFTCreateFilterTable_2.png"><img src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFTCreateFilterTable_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFTCreateFilterTable_thumb.png" style="border: 0px none; display: block; float: none; margin-left: auto; margin-right: auto;" title="XPathMFTCreateFilterTable" alt="XPathMFTCreateFilterTable" mce_src="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/LoadBalancingandtheRouter_89AA/XPathMFTCreateFilterTable_thumb.png" border="0" height="336" width="960"></a> </p>  <p>When the parent 
MessageFilterTable is asked by the RoutingService to return a list of 
endpoints that match a particular message, the parent MessageFilterTable
 in turn delegates this message to its own internal MessageFilterTables 
and MessageFilters, building the full result set and returning it to the
 Routing Service.</p>  <p>The sample RoundRobinMessageFilter inside the 
Routing Service’s Advanced Filters sample (<a href="http://msdn.microsoft.com/en-us/library/ee667249%28v=VS.100%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ee667249(v=VS.100).aspx">over
 here</a>) does much the same thing as the XPathMessageFilter.&nbsp; Now that
 we have a custom MessageFilterTable in the mix, we can use that to 
store state and coordinate the responses from the individual 
MessageFilters that ultimately gets returned to the parent 
MessageFilterTable.&nbsp; So can you build things this way?&nbsp; Absolutely.&nbsp; Is 
it the best answer? Probably not.&nbsp; At the end of the day you’re still 
stuffing state into the MessageFilter model, where it doesn’t belong.&nbsp; 
Furthermore, implementing custom MessageFilterTables is a pain because 
it requires you to stub in a lot of method calls that won’t ever be 
used.</p>  <p>Another answer is a different custom MessageFilter, which 
wouldn’t do RoundRobin specifically, but would send messages to a 
particular endpoint 1/n of the time, on average, where n is the number 
of possible destinations.&nbsp; This is also buildable, and could even be 
stateless, but could also be tricky because you’d have to figure out how
 to gaurentee that only one filter matched any given message.&nbsp; Just 
having say four filters that all compute a rand() between 0 and 1 and 
then determine if it’s in a particular range isn’t going to cut it, 
since multiple filters could independently report that they matched.&nbsp; I 
leave this one as an exercise to the reader, but one solution is to 
predefine your ranges and use some piece of message data (such as say, 
the time the message was sent, some random int that the client injected,
 or a hash of some other piece of data) to pick which filter matches.&nbsp; 
You could also get really creative with your use of the DynamicUpdate 
functionality to periodically switch out which endpoints the Routing 
Service was pointed to, but this seems a kludge.</p>  <p>The final 
solution, and the one I’m going to recommend, is to use a different 
extensibility point within the Routing Service.&nbsp; Note that the 
MessageFilterTable that we use is a MessageFilterTable&lt;<b>IEnumerable</b>&lt;ServiceEndpoint&gt;&gt;
 (something I <a href="http://blogs.msdn.com/routingrules/archive/2009/09/27/routing-service-features-part-1-content-based-routing.aspx" mce_href="http://blogs.msdn.com/routingrules/archive/2009/09/27/routing-service-features-part-1-content-based-routing.aspx">alluded
 to</a> a while ago).&nbsp; Why not write your own custom 
IEnumerable&lt;ServiceEndpoint&gt; and plug that into the right hand 
side of the MessageFilterTable?&nbsp; That way your filter selection could be
 simple (you could even use just a MatchAll if you didn’t need any other
 semantics).&nbsp; Here’s what that would probably look like:</p>  <p><span style="font-family: consolas; font-size: 14pt;"><span style="">&nbsp;<font size="3">&nbsp; </font></span><font size="3"><span style="color: blue;">class</span>
 <span style="color: rgb(43, 145, 175);">RoundRobinEndpointList</span> :
 <span style="color: rgb(43, 145, 175);">IEnumerable</span>&lt;<span style="color: rgb(43, 145, 175);">ServiceEndpoint</span>&gt;        <p>&nbsp;</p>
     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp; </span>{        <p>&nbsp;</p>
     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: rgb(43, 145, 175);">ServiceEndpoint</span>[] endpoints;   
     <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">int</span> head;        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span>
 RoundRobinEndpointList(<span style="color: blue;">params</span> <span style="color: rgb(43, 145, 175);">ServiceEndpoint</span>[] endpoints)   
     <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">if</span> (endpoints == <span style="color: blue;">null</span>
 || endpoints.Length == 0)        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">throw</span> <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">ArgumentException</span>(<span style="color: rgb(163, 21, 21);">"One or more ServiceEndpoints must be 
provided"</span>, <span style="color: rgb(163, 21, 21);">"endpoints"</span>);
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//Copy the list to ensure it doesn't change on us
 (and so we can lock() on our private copy)</span>        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">this</span>.endpoints
 = endpoints.ToArray();        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: rgb(43, 145, 175);">IEnumerator</span>&lt;<span style="color: rgb(43, 145, 175);">ServiceEndpoint</span>&gt; 
GetEnumerator()        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">int</span> 
currentHead;        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">lock</span> (<span style="color: blue;">this</span>.endpoints)        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>currentHead = <span style="color: blue;">this</span>.head++;        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">if</span> (<span style="color: blue;">this</span>.head == <span style="color: blue;">this</span>.endpoints.Length)        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//Wrap back to the start</span>        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">this</span>.head = 0;        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//If
 one just wanted to return 1 endpoint as opposed to a list with </span> 
       <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//backup endpoints this 'yield' is all that would
 be needed.</span>        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//yield return 
this.endpoints[currentHead];</span>        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//return
 results [current] ... [last]</span>        <p>&nbsp;</p>     </font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">for</span>
 (<span style="color: blue;">int</span> i = currentHead; i &lt; <span style="color: blue;">this</span>.endpoints.Length; i++)        <p>&nbsp;</p> 
    </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{    
    <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 </span><span style="color: blue;">yield</span> <span style="color: blue;">return</span> <span style="color: blue;">this</span>.endpoints[i];
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//return wrap-around (if any) [0] ... [current-1]</span>
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> i
 = 0; i &lt; currentHead; i++)        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">yield</span> <span style="color: blue;">return</span> <span style="color: blue;">this</span>.endpoints[i];
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: rgb(43, 145, 175);">IEnumerator</span> <span style="color: rgb(43, 145, 175);">IEnumerable</span>.GetEnumerator()    
    <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">return</span> <span style="color: blue;">this</span>.GetEnumerator();
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}
        <p>&nbsp;</p>     </font></span></p>  <p><span style="font-family: consolas; font-size: 14pt;"><font size="3"><span style="">&nbsp;&nbsp;&nbsp; </span>}</font></span></p>
  <p><span style="font-family: consolas; font-size: 14pt;"><font face="Times New Roman" size="3">Overall, this is a much more pleasing 
implementation of RoundRobin, and could easily be extended to other load
 balancing patterns as well.&nbsp; It has the distinction of being 1) quite 
small, 2) easy to understand (especially compared to the other 
implementations) 3) thread safe, and 4) performant (since we only need 
to lock on a copy of a list instead of the actual list that other 
MessageFilters might need to be using).</font></span></p>]]></content:encoded>
    </item>
    <item>
      <title>Another Router Sample!</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/another-router-sample</link>
      <pubDate>Wed, 10 Mar 2010 10:11:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2010/03/10/another-router-sample/</guid>
      <description><![CDATA[With the release of the .NET RC, the number of independent folks playing with the bits and putting...]]></description>
      <content:encoded><![CDATA[<P>With the release of the .NET RC, the number of independent folks playing with the bits and putting together projects has grown tremendously.&nbsp; This is fantastic to see, because the more eyes we get on the product and the more demo code written the better the feedback.&nbsp; I love customer feedback :)</P>
<P>&nbsp;Here's another Routing Service project, this time from Rochard Seroter, who put together a "multi-type" Routing Service hosted in WAS (the easy way this time).&nbsp; Here's the <A href="http://seroter.wordpress.com/2010/03/09/simpler-way-of-hosting-the-wcf-4-0-routing-service-in-iis7/" target=_blank mce_href="http://seroter.wordpress.com/2010/03/09/simpler-way-of-hosting-the-wcf-4-0-routing-service-in-iis7/">link</A>.</P>
<P>Richard also had an interesting question: "D<SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: EN-US">o the contracts of all&nbsp;the services behind the routing service need to implement the same contract?&nbsp; Otherwise, where do you do the&nbsp;format transformation?&nbsp; In a&nbsp;custom behavior?&nbsp; Or would you recommend that the service accept an untyped object and cast it to the known type later?"</SPAN></P>
<P><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: EN-US">This is a great question as it points to one of the strengths of the Routing Service, which is its typelessness.&nbsp; The question now is what happens when the "types" presented at the front of the Routing Service don't map to the ones that the backend services are expecting?</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-fareast-language: EN-US"></P>
<P>To answer Richard's question:&nbsp; No, they don’t have to have the same contract.&nbsp; By default the Router doesn’t touch the message body: we take whatever was presented by the client or returned from the service (there's one notable exception to this related to processing Faults).&nbsp; If your client is presenting messages that your remote services can’t understand (are incompatible) then yeah, you’ll need a transformation of some sort.&nbsp; I’ve seen this done a few ways:<BR>&nbsp;<BR>1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A generic XSLT behavior, attached at either the inbound service endpoint (applied to all messages) or the outbound endpoint (transformation specific to this destination).<BR>2)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The use of something like <A href="http://automapper.codeplex.com/" target=_blank mce_href="http://automapper.codeplex.com/">automapper</A> in a behavior.&nbsp; The downside of Automapper is that is presumes you're working with strongly typed&nbsp;objects, which you aren't by default at the Routing Service (though you could write&nbsp;some code that translated the XML message into your strongly typed objects and then converted it with AutoMapper.&nbsp;&nbsp;(I'd probably just write the XSLT, but that's a less robust solution).<BR>&nbsp;<BR>Going untyped is a third option, but is only necessary if you’re going to do the mapping/transformation/casting later.&nbsp; <BR><BR style="mso-special-character: line-break"><BR style="mso-special-character: line-break">Let's keep those Router sample projects coming!</P>
<P>&nbsp;-Matt</P></SPAN>]]></content:encoded>
    </item>
    <item>
      <title>Multicast Router Example</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/multicast-router-example</link>
      <pubDate>Tue, 02 Mar 2010 18:21:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2010/03/02/multicast-router-example/</guid>
      <description><![CDATA[Over the last few weeks I watched (and occasionally chimed in) while a coworker of mine (Danny...]]></description>
      <content:encoded><![CDATA[<p>Over the last few weeks I watched (and occasionally chimed in) while a coworker of mine (Danny Cohen) built a pretty comprehensive example of multicasting at the Routing Service over at <a title="Routing Service Multicast Sample" href="http://dannycohen.info/2010/03/02/wcf-4-routing-service-multicast-sample/" mce_href="http://dannycohen.info/2010/03/02/wcf-4-routing-service-multicast-sample/">his blog</a>.&#160; I would consider this a good reference for anyone looking to do something similar with the Routing Service.&#160; Here’s what he built:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/MulticastRouterExample_10461/routingservicemulticast2_2.jpg" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/MulticastRouterExample_10461/routingservicemulticast2_2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="routingservicemulticast2" border="0" alt="routingservicemulticast2" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/MulticastRouterExample_10461/routingservicemulticast2_thumb.jpg" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/MulticastRouterExample_10461/routingservicemulticast2_thumb.jpg" width="516" height="476" /></a> </p>  <p>Go check it out!</p>]]></content:encoded>
    </item>
    <item>
      <title>Routing in WAS</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/routing-in-was</link>
      <pubDate>Mon, 01 Mar 2010 10:06:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2010/03/01/routing-in-was/</guid>
      <description><![CDATA[For those of you who have your services hosted in WAS/IIS, the trickiest part of getting the Routing...]]></description>
      <content:encoded><![CDATA[<P>For those of you who have your services hosted in WAS/IIS, the trickiest part of getting the Routing Service working is remembering that you need to reference the fully qualified assembly name (since System.ServiceModel.Routing.dll is in the GAC instead of in your service directory).&nbsp; A good writeup on solving a common routing scenario with WAS hosted services is located <A title="Routing with WAS" href="http://blogs.microsoft.co.il/blogs/berniea/archive/2010/01/12/wcf-4-0-routing-with-was.aspx" mce_href="http://blogs.microsoft.co.il/blogs/berniea/archive/2010/01/12/wcf-4-0-routing-with-was.aspx">over here</A>.&nbsp; Note that in this example we see the following capabilities used:</P>
<UL>
<LI>Routing on message body data (routeOnHeadersOnly=false)</LI>
<LI>WAS Hosted Routing Service</LI>
<LI>use of the Namespace table to introduce custom namespaces used in the messages</LI></UL>
<P>&nbsp;Nicely done :)</P>
<P>&nbsp;For reference: the fully qualified name of the Routing Service is:</P>
<P><SPAN style="COLOR: #0000ff">"System.ServiceModel.Routing.RoutingService, System.ServiceModel.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&nbsp; </SPAN></P>
<P><SPAN style="COLOR: #0000ff"><FONT color=#000000>This would be the path you referenced either in the Service tag of your SVC file, and in some situations also when referencing the service name inside your Web.config files.</FONT></SPAN></P>
<P>&nbsp;-Matt</P>
<P mce_keep="true">&nbsp;</P>
<P mce_keep="true">&nbsp;</P>]]></content:encoded>
    </item>
    <item>
      <title>Routing Service - 10-4!</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/routing-service-10-4</link>
      <pubDate>Thu, 11 Feb 2010 11:06:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2010/02/11/routing-service-10-4/</guid>
      <description><![CDATA[Ron Jacobs just put up a new video demonstrating the Routing Service over on 10-4, the series of...]]></description>
      <content:encoded><![CDATA[<P>Ron Jacobs just put up a new video demonstrating the Routing Service over on 10-4, the series of videos put together to show off what's new with VS2010 and .NET 4.&nbsp; The 10-4 videos are located <A title="10-4 Videos" href="https://channel9.msdn.com/shows/10-4/" target=_blank mce_href="https://channel9.msdn.com/shows/10-4/">here</A>, and Ron's quick demo of the Routing Service is <A title="The New WCF Routing Service" href="https://channel9.msdn.com/shows/10-4/10-4-Episode-40-The-New-WCF-Routing-Service/" mce_href="https://channel9.msdn.com/shows/10-4/10-4-Episode-40-The-New-WCF-Routing-Service/">Episode 40</A>.&nbsp; You can also find Ron on <A title="Ron Jacobs" href="http://blogs.msdn.com/rjacobs/" target=_blank mce_href="http://blogs.msdn.com/rjacobs/">his blog</A>, and more about WCF and WF over on the <A title="the .NET Endpoint" href="http://blogs.msdn.com/endpoint/" target=_blank mce_href="http://blogs.msdn.com/endpoint/">Endpoint Blog</A>.</P>
<P>&nbsp;Enjoy!</P>
<P>-Matt</P>]]></content:encoded>
    </item>
    <item>
      <title>Routing Service Features – Dynamic Reconfiguration</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/routing-service-features-dynamic-reconfiguration</link>
      <pubDate>Mon, 08 Feb 2010 17:35:42 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2010/02/08/routing-service-features-dynamic-reconfiguration/</guid>
      <description><![CDATA[The final in the broad posts about the capabilities of the Routing Service, today we're going to...]]></description>
      <content:encoded><![CDATA[<p>The final in the broad posts about the capabilities of the Routing Service, today we're going to cover Dynamic Reconfiguration.&#160; Dynamic Reconfig is really one of the neatest things about the Routing Service (in my opinion) as it opens up a whole new set of scenarios that otherwise would have required a lot of custom code and tricks to implement.</p>  <p>Dynamic reconfig is the result of questions like the following:</p>  <ul>   <li>When self or web hosting how do I get updates into the Router?</li>    <li>During runtime what is it even <em>safe</em> to change?</li>    <li>What if my deployment changes (services move)?</li>    <li>What happens if I need to add a new rule to my Router to capture new traffic?</li>    <li>What happens if I notice some error in my configuration that I want to adjust?</li>    <li>How do I get my rules into the Routing Service if I decide to store them somewhere else?</li> </ul>  <p>When building the Routing Service, it was initially (and still is primarily) configuration driven.&#160; If you were self hosted, and you wanted to change your configuration, you’d have to throw together some file watcher and be able to know how not to interrupt messages and connections that were in flight before shutting down the host to pick up the new config.&#160; This is non-trivial, especially outside of the service implementation proper where user code would live.&#160; If you were webhosted (in IIS) you’d run into the “my config changed and now I have a (seemingly arbitrary) set amount of time before my host recycles and I lose any connections that were in play”.&#160; Since sorting out these questions is tricky enough, we felt like we could add some value by not making our customers deal with them.&#160; The solution we arrived at is Dynamic Reconfig.&#160; </p>  <p>Let’s rewind for a second and remember how we configure the Routing Service normally through code:</p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//set up some communication defaults</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">string</span> clientAddress = <span style="color: #a31515">&quot;http://localhost:8000/servicemodelsamples/service&quot;</span>;      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: blue">string</span> routerAddress = <span style="color: #a31515"><span style="color: #a31515">&quot;http://localhost:8000/routingservice/service&quot;</span>;</span></span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">Binding</span> routerBinding = <span style="color: blue">new</span> <span style="color: #2b91af">WSHttpBinding</span>();      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">Binding</span> clientBinding = <span style="color: blue">new</span> <span style="color: #2b91af">WSHttpBinding</span>();      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//add the endpoint the router will use to receive messages</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>serviceHost.AddServiceEndpoint(<span style="color: blue">typeof</span>(<span style="color: #2b91af">IRequestReplyRouter</span>), routerBinding, routerAddress);      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//create the client endpoint the router will route messages to</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">ContractDescription</span> contract = <span style="color: #2b91af">ContractDescription</span>.GetContract(<span style="color: blue">typeof</span>(<span style="color: #2b91af">IRequestReplyRouter</span>));      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">ServiceEndpoint</span> client = <span style="color: blue">new</span> <span style="color: #2b91af">ServiceEndpoint</span>(contract, clientBinding, <span style="color: blue">new</span> <span style="color: #2b91af">EndpointAddress</span>(clientAddress));      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//create a new routing configuration object</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">RoutingConfiguration</span> rc = <span style="color: blue">new</span> <span style="color: #2b91af">RoutingConfiguration</span>();      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//create the endpoint list that contains the service endpoints we want to route to</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//in this case we have only one</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">ServiceEndpoint</span>&gt; endpointList = <span style="color: blue">new</span> <span style="color: #2b91af">List</span>&lt;<span style="color: #2b91af">ServiceEndpoint</span>&gt;();      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>endpointList.Add(client);      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//add a MatchAll filter to the Router's filter table</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//map it to the endpoint list defined earlier</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//when a message matches this filter, it will be sent to the endpoint contained in the list</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>rc.FilterTable.Add(<span style="color: blue">new</span> <span style="color: #2b91af">MatchAllMessageFilter</span>(), endpointList);      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: green">//attach a new RoutingBehavior with this RoutingConfiguration to the service host</span>      <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>serviceHost.Description.Behaviors.Add(<span style="color: blue">new</span> <span style="color: #2b91af">RoutingBehavior</span>(rc));      <p></p>   </span></p>  <p class="MsoNormal">Note how most of the logic is actually encapsulated in one object, the <span style="color: #2b91af">RoutingConfiguration</span>.&#160; The RoutingConfiguration object describes the message filter table that the Routing Service should use, which includes the message filters and client endpoints. </p>  <p class="MsoNormal">Dynamic config works by allowing you to hand the Routing Service a new RoutingConfiguration during runtime, which the Routing Service then picks up and uses.&#160; In doing so, we make sure that messages and connections that were in flight continue to use the RoutingConfiguration (and thus filters) that was in place when they started being processed.</p>  <p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesDynamicReconfigura_DA53/dynamicReconfig_2.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesDynamicReconfigura_DA53/dynamicReconfig_2.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="dynamicReconfig" border="0" alt="dynamicReconfig" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesDynamicReconfigura_DA53/dynamicReconfig_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesDynamicReconfigura_DA53/dynamicReconfig_thumb.png" width="688" height="467" /></a> As the diagram indicates, the API for applying a new RoutingConfiguration to the Router during runtime is (creatively) called “ApplyConfiguration”. It takes a RoutingConfiguration object, and is located on a ServiceExtention attached to the Routing Service called the RoutingExtension.&#160; We used a ServiceExtension so that you could write your own ServiceExtension code that is able to find our extension and call this method.&#160; Your ServiceExtension would have some code similar to that above: newing up a RoutingConfiguration, creating some MessageFilters and Endpoints, and then calling ApplyConfiguration on our extension.&#160; </p>  <p class="MsoNormal">But where do you get the information for building these filters?&#160; Well, it could be anywhere, but the key is that you probably want it to be event driven: something happens, a callback fires, and that data is used to create a new set of filters.&#160; What is that event?&#160; Well, it could be a file watcher watching some external configuration store, it could be a Discovery Announcement, it could be a SQL or Velocity Cache event notification, whatever.&#160; Note that since this can happen whenever you want, it can happen immediately on service startup, meaning that you’re free to leave the Routing Service’s App or Web.config entirely out of the process and do it all in memory dynamically.</p>  <p class="MsoNormal">As far as the performance of applying new rules, it’s pretty snappy, since internally it’s basically a pointer move.&#160; The far more complex step is the construction of the rules themselves.&#160; What about the impact to the memory footprint of having all these extra sets of rules hanging around?&#160; Well luckily MessageFilters and MessageFilterTables are pretty small, so by themselves they’re not a big problem.&#160; Furthermore, since a RoutingConfiguration is only referred to by the sessions that are using it, once all those sessions are closed, that RoutingConfiguration gets GC’d.&#160; In some ad-hoc tests we did where we opened connections that never died and also kept calling ApplyConfiguration() with a new RoutingConfiguration each time, we ran out of TCP connections on the box before we ran out of memory.&#160; Unless your RoutingConfiguration’s MessageFilterTable is exceptionally huge, you’re very unlikely to see any issues as a result of this feature (besides, hopefully, an increase in the flexibility of the solutions you’re able to build).</p>]]></content:encoded>
    </item>
    <item>
      <title>Routing Service Features - Error Handling Part 2</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/routing-service-features-error-handling-part-2</link>
      <pubDate>Wed, 30 Dec 2009 14:31:20 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2009/12/30/routing-service-features-error-handling-part-2/</guid>
      <description><![CDATA[Take a deep breath, this post is a bit of a doozy :)  In the last post I discussed the Error...]]></description>
      <content:encoded><![CDATA[<p>Take a deep breath, this post is a bit of a doozy :)</p>  <p>In the <a href="http://blogs.msdn.com/routingrules/archive/2009/12/10/routing-service-features-error-handling.aspx" target="_blank">last post</a> I discussed the Error Handling capabilities of the Routing Service.&#160; In that post I showed how error handling can be added to lots of common scenarios in order to provide a more robust experience for clients.&#160; These scenarios are useful, but they don’t illustrate the strengths of the error handling capabilities, which is what happens when the Routing Service is dealing with more complex messaging patterns and capabilities, such as multicast, sessions, and transactions.&#160; In this post, we’ll examine some of these patterns and how the Routing Service deals with them when handling errors. Lets say you have the Routing Service configured as a part of the following scenario:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2_2.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ErrorHandling2" border="0" alt="ErrorHandling2" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2_thumb.png" width="510" height="285" /></a></p>  <p>In this example, you have some inbound queue into which “work messages” are delivered (either by clients, other services, etc). You’re using the Routing Service to make sure that a record of that message is delivered to exactly one of your Service Queues (to make sure the work gets done) and to exactly one of your Logging Queues (to make sure the work is recorded).&#160;&#160; The routing configuration would look something like this (presuming all the queue endpoints had already been defined):</p>  <p style="line-height: normal; margin-bottom: 0pt" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"></span></p>  <p><span style="font-family: consolas; color: blue; font-size: 9.5pt"></span></p>  <p></p>  <p></p>  <p></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpFirst"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">routing</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">filters</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;!--</span><span style="font-family: consolas; color: green; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> Create a match all filter </span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">--&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">filter</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: consolas; color: red; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">name</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">=</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&quot;<span style="color: blue">MatchAllMessageFilter1</span>&quot;<span style="color: blue"> </span><span style="color: red">filterType</span><span style="color: blue">=</span>&quot;<span style="color: blue">MatchAll</span>&quot;<span style="color: blue"> /&gt;</span> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">filters</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">filterTables</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">filterTable</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: consolas; color: red; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">name</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">=</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&quot;<span style="color: blue">multicastTable</span>&quot;<span style="color: blue">&gt;</span> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160; </span>&lt;!--</span><span style="font-family: consolas; color: green; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> Add two entries to the filter table so that when a message comes in it is multicasted to both lists of queues </span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">--&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">add</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: consolas; color: red; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">filterName</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">=</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&quot;<span style="color: blue">MatchAllMessageFilter1</span>&quot;<span style="color: blue"> </span><span style="color: red">endpointName</span><span style="color: blue">=</span>&quot;<span style="color: blue">primaryServiceQueue</span>&quot;<span style="color: blue"> </span><span style="color: red">backupList</span><span style="color: blue">=</span>&quot;<span style="color: blue">backupServiceEndpoints</span>&quot;<span style="color: blue">/&gt;</span>       <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">add</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: consolas; color: red; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">filterName</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">=</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&quot;<span style="color: blue">MatchAllMessageFilter1</span>&quot;<span style="color: blue"> </span><span style="color: red">endpointName</span><span style="color: blue">=</span>&quot;<span style="color: blue">primaryLoggingQueue</span>&quot;<span style="color: blue"> </span><span style="color: red">backupList</span><span style="color: blue">=</span>&quot;<span style="color: blue">backupLoggingEndpoints</span>&quot;<span style="color: blue">/&gt;</span> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">filterTable</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">filterTables</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;!--</span><span style="font-family: consolas; color: green; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> Define the backup service and logging endpoint lists </span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">--&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">backupLists</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">backupList</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: consolas; color: red; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">name</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">=</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&quot;<span style="color: blue">backupServiceEndpoints</span>&quot;<span style="color: blue">&gt;</span> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">add</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: consolas; color: red; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">endpointName</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">=</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&quot;<span style="color: blue">backupServiceQueue</span>&quot;<span style="color: blue"> /&gt;</span> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">backupList</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">backupList</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: consolas; color: red; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">name</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">=</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&quot;<span style="color: blue">backupLoggingEndpoints</span>&quot;<span style="color: blue">&gt;</span> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">add</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: consolas; color: red; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">endpointName</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">=</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&quot;<span style="color: blue">backupLoggingQueue</span>&quot;<span style="color: blue"> /&gt;</span> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">backupList</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">backupLists</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt;</span><span style="font-family: consolas; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"> </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto" class="MsoNormalCxSpMiddle"><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">routing</span><span style="font-family: consolas; color: blue; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">&gt; </span><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;; font-size: 9pt; mso-fareast-font-family: &#39;Times New Roman&#39;; mso-ansi-language: en" lang="EN">     <p></p>   </span></p>  <p>What you don’t want is for work to be done that isn’t recorded somewhere (that’s how customers don’t get billed) or to record that work was done that actually wasn’t (that’s how customers get billed incorrectly and end up upset).&#160; Thus, this configuration, with the Routing Service should successfully move the message out of the inbound queue only if the action of inserting the message into exactly one of the Service Queues AND exactly one of the logging queues.&#160; In order to do this, the Routing Service utilizes both the Receive Context features of .NET 4 and transactions.</p>  <p>Receive Context is used to obtain a temporary lock (peek-lock) on the message inside the inbound queue so that other readers from the queue (potentially other Routing Services) don’t attempt to operate on the message while this Routing Service is.&#160; Next the Routing Service reads the message, and feeds it into the Message Filter Table defined here, which matches the message to the two filter entries (the primaryServiceQueue/backup list and corresponding logging endpoints).&#160; Because there were multiple matches, the message is multicast to both destinations (in this case the primaryServiceQueue and the primaryLoggingQueue).&#160; Because there are messaging guarantees that the Routing Service is trying to meet, it first creates a transaction.&#160; The Routing Service will attempt to do the necessary work inside this transaction, and then will only commit the transaction if everything succeeds.</p>  <p>When there’s nothing wrong, the result of placing a message in the inbound queue looks like this:<img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ErrorHandling2.1" border="0" alt="ErrorHandling2.1" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2.1_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2.1_thumb.png" width="510" height="285" /></p>  <p>If we turn on tracing and get a look at the events that are coming out of the Routing Service we get a good idea of what’s going on:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace_4.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace_4.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ErrorHandling2trace" border="0" alt="ErrorHandling2trace" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace_thumb_1.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace_thumb_1.png" width="786" height="190" /></a> </p>  <p>So that’s the happy path, but what happens when the various queues are unavailable/unreachable or the Routing Service encounters errors when trying to insert the message into the destination queues (say they don’t exist anymore for some reason or that the destination host is unreachable)?&#160; Clearly if the primary service or logging queue is down, the Routing Service will use the backups instead.<a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2.2_2.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2.2_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ErrorHandling2.2" border="0" alt="ErrorHandling2.2" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2.2_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2.2_thumb.png" width="506" height="281" /></a>But what’s going on inside the Routing Service when this happens?</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace2_2.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace2_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ErrorHandling2trace2" border="0" alt="ErrorHandling2trace2" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace2_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace2_thumb.png" width="817" height="252" /></a></p>  <p>We see that when the initial send to the primary Service Endpoint fails, the Routing Service automatically knows that the current transaction is no longer any good, and thus it spins up a new transaction for sending the message to the backup service queue.&#160; When these sends succeed, the second transaction is committed. (Not pictured is the prior transaction being discarded).&#160;&#160; This pattern of discarding the current transaction, moving the message to a backup endpoint, and then creating a new transaction and trying again will be repeated until the message is successfully sent to all of the destinations indicated and the transaction is able to commit.</p>  <p>What about when the Routing Service is unable to deliver the message with the transactional guarantees in the way that it was configured to do so (say in a case where we run out of backup endpoints to send the message to)?&#160; In this case, the ultimate behavior is configurable as a setting with MSMQ, but a common action is to move the message out of the inbound queue and into a DLQ.&#160; In order to do this, the Routing Service, after trying to create and use a transaction to send the message to some functional combination of the specified destinations, calls Abandon on the Receive Context, indicating to the inbound queue that it was unable to process the message correctly.</p>  <p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ErrorHandling2.3" border="0" alt="ErrorHandling2.3" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2.3_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2.3_thumb.png" width="510" height="285" /></p>  <p>And here’s the trace:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace3_2.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace3_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ErrorHandling2trace3" border="0" alt="ErrorHandling2trace3" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace3_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorHandling2trace3_thumb.png" width="830" height="367" /></a> </p>  <p></p>  <p>This kind of advanced processing works even when there are sessions (or sets) of messages that are being processed.&#160; In this case, as the session of messages passes through the Routing Service, the Routing Service temporarily caches each message so that it can be replayed to the last destination it was successfully routed to.&#160; Only when all messages are successfully sent to a endpoint and successfully received can the transaction be committed and the messages marked as successfully sent.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorsInSessions_2.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorsInSessions_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ErrorsInSessions" border="0" alt="ErrorsInSessions" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorsInSessions_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart2_B238/ErrorsInSessions_thumb.png" width="576" height="425" /></a> </p>  <p>&#160;</p>  <p></p>  <p>Whew! So what does this all mean?&#160; This means that we’ve baked a lot of complex state tracking into the Routing Service, so that even when your message patterns, filter rules, and transactional/sessionful requirements change, we’ve got you covered on the robustness front.&#160; The Routing Service is going to take a lot of pains to deliver messages and handle this logic so that you don’t have to write it into your clients.</p>]]></content:encoded>
    </item>
    <item>
      <title>Routing Service Features - Error Handling Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/routingrules/routing-service-features-error-handling-part-1</link>
      <pubDate>Thu, 10 Dec 2009 14:20:00 GMT</pubDate>
      <dc:creator><![CDATA[Matt Snider]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/routingrules/2009/12/10/routing-service-features-error-handling-part-1/</guid>
      <description><![CDATA[Today we continue the set of articles on the core features of the RoutingService.&#160; In this...]]></description>
      <content:encoded><![CDATA[<p>Today we <a title="Routing Service Features Recap" href="http://blogs.msdn.com/routingrules/archive/2009/09/20/routing-service-features-recap.aspx" target="_blank" mce_href="http://blogs.msdn.com/routingrules/archive/2009/09/20/routing-service-features-recap.aspx">continue</a> the set of articles on the core features of the RoutingService.&#160; In this post, I'll explain Error Handling, a great feature that provides value to both common an high-end uses of the Routing Service by providing a way to make your application more tolerant of temporary communication and network errors.</p>  <p>First: what do we mean when we say errors?&#160; In this case, we're talking primarily about CommunicationExceptions and TimeoutExceptions, two classes of Exception that (can) occur commonly in a distributed system.&#160; Communication Exceptions are things like EndpointNotFoundExceptions that generally indicate that the service that you were trying to talk to was down, didn't provide a correct response, or didn’t understand the message you sent it.&#160; TimeoutExceptions are just what they sound like: you've been stuck waiting for a response for too long.&#160; Either of these could happen for a variety of reasons: temporary network outage, messages that get lost on the network, glitches or bugs in the configuration of the services involved, implementation issues of the remote service, etc.</p>  <p>Since the Routing Service is acting on behalf of the client, we will sometimes see these errors.&#160; Now, we could just forward these exceptions back to the client and let the client application deal with them.&#160; However, since we're already participating in the message flow, there's an opportunity for us to do something else, which can help your application be more robust and tolerant of these common (and frequently temporary) errors.&#160; We allow you to configure a set of alternate endpoints that the Routing Service should use as backups when a particular endpoint returns an exception.&#160; In these cases the Routing Service will &quot;fail-over&quot; to the backup endpoint and try to deliver your message again.</p>  <p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ErrorHandling1" border="0" alt="ErrorHandling1" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart1_EA42/ErrorHandling1_thumb.png" original-url="http://blogs.msdn.com/blogfiles/routingrules/WindowsLiveWriter/RoutingServiceFeaturesErrorHandlingPart1_EA42/ErrorHandling1_thumb.png" width="462" height="264" /><font color="#000000"></font></p>  <p><font color="#000000"></font></p>  <p>Aside from a slightly slower response (after all, the Routing Service does need to wait for the exception to occur before taking action), the client is none the wiser.&#160; </p>  <p>As we’ve seen before, when defining an entry in the MessageFilterTable, I normally map a MessageFilter to a particular destination endpoint like this:</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">add</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">filterName</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">&quot;<span style="color: blue">someFilter1</span>&quot;<span style="color: blue"> </span><span style="color: red">endpointName</span><span style="color: blue">=</span>&quot;<span style="color: blue"><span style="color: blue">someDestinationEndpoint1</span></span>&quot;<span style="color: blue"> </span><span style="color: blue">/&gt;</span></span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue"></span></span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">When defining backup endpoints, this changes slightly, as we have to both define the backup list, and then reference it in the filter table entry. First, to create the backup list, we define a new section inside of the &lt;routing&gt; section called, appropriately “backupLists”.&#160; This is where we create a particular list and add endpoints to it.&#160; </p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">&#160;</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">backupLists</span><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">&gt;</span></span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">backupList <span style="font-family: consolas; color: red; font-size: 9.5pt">name</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;</span><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">backupList1&quot;</span></span></span><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">&gt;</span></span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">add <span style="font-family: consolas; color: red; font-size: 9.5pt">endpointName</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;</span><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">backup&quot;</span></span></span><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">&gt;</span></span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">add <span style="font-family: consolas; color: red; font-size: 9.5pt">endpointName</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;</span><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">backup2&quot;</span></span></span><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">&gt;</span></span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: blue">&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">backupList<span style="color: blue">&gt;</span></span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">backupLists<span style="color: blue">&gt;</span></span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">&#160;</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">To actually use the list of alternates that we built, add a reference to the list to the filter table entry, like so:</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">&#160;</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">add</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">filterName</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">&quot;<span style="color: blue">someFilter1</span>&quot;<span style="color: blue"> </span><span style="color: red">endpointName</span><span style="color: blue">=</span>&quot;<span style="color: blue"><span style="color: blue">someDestinationEndpoint1</span></span>&quot; <span style="color: red">backupList</span><span style="color: blue">=</span>&quot;<span style="color: blue"><span style="color: blue">backupList1</span></span>&quot;<span style="color: blue">/&gt;</span></span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">&#160;</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">In code, setting up backups would look like this:</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">&#160;</p>  <p style="line-height: normal; text-indent: 0.5in; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; background: white; color: green; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">//assume the endpoint objects and the filter objects already exist     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal" align="left"><span style="font-family: &quot;Courier New&quot;; background: white; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: &quot;Courier New&quot;; background: white; color: #2b91af; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">List</span><span style="font-family: &quot;Courier New&quot;; background: white; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">&lt;</span><span style="font-family: &quot;Courier New&quot;; background: white; color: #2b91af; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">ServiceEndpoint</span><span style="font-family: &quot;Courier New&quot;; background: white; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">&gt; endpointList = </span><span style="font-family: &quot;Courier New&quot;; background: white; color: blue; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">new</span><span style="font-family: &quot;Courier New&quot;; background: white; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa"> </span><span style="font-family: &quot;Courier New&quot;; background: white; color: #2b91af; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">List</span><span style="font-family: &quot;Courier New&quot;; background: white; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">&lt;</span><span style="font-family: &quot;Courier New&quot;; background: white; color: #2b91af; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">ServiceEndpoint</span><span style="font-family: &quot;Courier New&quot;; background: white; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">&gt;(){someDestinationEndpoint1, backup, backup2};     <p></p>   </span></p>  <p style="line-height: normal; text-indent: 0.5in; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal" align="left"><span style="font-family: &quot;Courier New&quot;; color: #2b91af; font-size: 10pt">RoutingConfiguration</span><span style="font-family: &quot;Courier New&quot;; font-size: 10pt"> rc = <span style="color: blue">new</span> <span style="color: #2b91af">RoutingConfiguration</span>();</span><span style="font-family: &quot;Courier New&quot;; background: white; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">     <p></p>   </span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal" align="left"><span style="font-family: &quot;Courier New&quot;; background: white; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span>rc.FilterTable.Add(someFilter1, endpointList);</span></p>  <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: &quot;Courier New&quot;; background: white; color: black; font-size: 10pt; mso-bidi-font-size: 11.0pt; mso-highlight: white; mso-bidi-language: ar-sa">     <p></p>   </span></p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">The order that the endpoints are added to the list are the order in which they will be attempted.&#160; With this configuration, first the endpoint referenced by the endpointName would be tried.&#160; Should the connection to that endpoint fail or time out, the first endpoint in the backup list (“backup”) would be tried.&#160; Only if communication to that destination failed would the message be sent to backup2.&#160; Should backup2 fail, the client would get the same exception/error they normally would have had there been no alternates specified.&#160; In this way we add reliability without changing the underlying model expected by the client.&#160; </p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">&#160;</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">Error handling can be added to pretty much any messaging pattern or protocol: one-way, request response, duplex, multicast, sessionful, etc.&#160; The logic present knows how to handle everything from single-message request-response messages (basicHttp) to sessionful, transactional messages (MSMQ).&#160; These more advanced error handling semantics will be the topic of the next post, since talking through their state can be somewhat tricky.</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">&#160;</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">Enjoy!</p>  <p style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none" class="MsoNormal">-Matt</p>]]></content:encoded>
    </item>
  </channel>
</rss>