{"id":130,"date":"2006-07-06T13:22:37","date_gmt":"2006-07-06T20:22:37","guid":{"rendered":"http:\/\/kennyw.com\/indigo\/130"},"modified":"2006-07-06T13:22:37","modified_gmt":"2006-07-06T20:22:37","slug":"the-effect-of-isoneway-on-operations","status":"publish","type":"post","link":"https:\/\/kennyw.com\/?p=130","title":{"rendered":"The effect of IsOneWay on Operations"},"content":{"rendered":"<p>The other day I was asked &#8220;why should I use IsOneWay=true on my OperationContract? What does it actually do or optimize?&#8221;.  In other words, what are the technical differences between:<\/p>\n<p><code>[<\/code><code class=\"classname\">OperationContract<\/code><code><\/code><code>]<\/code><br \/>\n<code class=\"keyword\">void<\/code><code> Send(MyMessage message);<\/code><\/p>\n<p>and:<br \/>\n<code>[<\/code><code class=\"classname\">OperationContract<\/code><code>(IsOneWay=<\/code><code class=\"keyword\">true<\/code>)<code>]<\/code><br \/>\n<code class=\"keyword\">void<\/code><code> Send(MyMessage message);<\/code><\/p>\n<p>The first difference is semantics &#8212; even though you have a <code class=\"keyword\">void<\/code> method, if you don&#8217;t mark the Operation with IsOneWay then we will wait for an ACK\/NACK reply. There are a few other behavioral changes when you choose IsOneWay:<\/p>\n<ol>\n<li>The service will release the connection (or complete the HTTP request\/response by <a href=\"http:\/\/kennyw.com\/indigo\/119\">replying with null<\/a>, etc) <strong>before<\/strong> dispatching to user code. If the operation is not marked with IsOneWay then our Dispatcher won&#8217;t reply until the Operation has completed<\/li>\n<li>ServiceModel Runtime will ask for IOutputChannel first, before falling back to IRequestChannel or IDuplexSessionChannel if IOutputChannel isn&#8217;t available.  This allows the underlying stack to make optimizations on send\/receive.<\/li>\n<li>Service Model Faults will not be returned, so Exceptions caused by the Message-level processing are not propagated to the client (though it&#8217;s still possible to receive a framing-level fault such as an HTTP status code error).<\/li>\n<\/ol>\n<p>In general, you should have your methods represent their semantic usages. This will help your overall design and allow the system to know best how to adapt to your intended usage. So if you are writing a true one-way notification (or building upon one-way methods for a duplex contract), be sure to remember the <code>IsOneWay=<\/code><code class=\"keyword\">true<\/code> annotation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The other day I was asked &#8220;why should I use IsOneWay=true on my OperationContract? What does it actually do or optimize?&#8221;. In other words, what are the technical differences between: [OperationContract] void Send(MyMessage message); and: [OperationContract(IsOneWay=true)] void Send(MyMessage message); The first difference is semantics &#8212; even though you have a void method, if you don&#8217;t [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-indigo"],"_links":{"self":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":0,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions"}],"wp:attachment":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}