<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: In-Order Messaging a Myth?</title>
	<atom:link href="http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/</link>
	<description>Enterprise Development Expert &#38; SOA Specialist</description>
	<lastBuildDate>Sun, 14 Mar 2010 06:27:00 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: [Podcast] Message Ordering: Is it Cost Effective?</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-13333</link>
		<dc:creator>[Podcast] Message Ordering: Is it Cost Effective?</dc:creator>
		<pubDate>Tue, 01 Jan 2008 23:01:26 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-13333</guid>
		<description>[...] Blog post: In-Order Messaging a Myth? [...]</description>
		<content:encoded><![CDATA[<p>[...] Blog post: In-Order Messaging a Myth? [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Handling messages out of order</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-12528</link>
		<dc:creator>Handling messages out of order</dc:creator>
		<pubDate>Sat, 15 Dec 2007 23:22:34 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-12528</guid>
		<description>[...] wanted to follow up on my recent post, &#8220;In order messaging a myth?&#8221; by showing the exact code that solves the issue. I have a podcast waiting to come online [...]</description>
		<content:encoded><![CDATA[<p>[...] wanted to follow up on my recent post, &#8220;In order messaging a myth?&#8221; by showing the exact code that solves the issue. I have a podcast waiting to come online [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-12458</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Fri, 14 Dec 2007 09:19:08 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-12458</guid>
		<description>John,

I&#039;ve pretty sure that a multi-threaded solution, allowing multiple messages to be processed at the same time, would, in the general case outperform (in terms of throughput) a single-threaded solution.

That said, my experience is that &quot;the more threads, the better&quot; is false. There is usually a limit to the throughput that threading buys by  itself.

In many scenarios, different messages affect different sets of data; that&#039;s the sweet spot for multi-threading. In a scenario where most messages deal with the same set of data, a single-threaded solution would probably work better.

So, we&#039;re agreed after all.</description>
		<content:encoded><![CDATA[<p>John,</p>
<p>I&#8217;ve pretty sure that a multi-threaded solution, allowing multiple messages to be processed at the same time, would, in the general case outperform (in terms of throughput) a single-threaded solution.</p>
<p>That said, my experience is that &#8220;the more threads, the better&#8221; is false. There is usually a limit to the throughput that threading buys by  itself.</p>
<p>In many scenarios, different messages affect different sets of data; that&#8217;s the sweet spot for multi-threading. In a scenario where most messages deal with the same set of data, a single-threaded solution would probably work better.</p>
<p>So, we&#8217;re agreed after all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-12457</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Fri, 14 Dec 2007 09:15:10 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-12457</guid>
		<description>Oran,

Thanks for the response - I&#039;ve posted a clarification of my question there.</description>
		<content:encoded><![CDATA[<p>Oran,</p>
<p>Thanks for the response &#8211; I&#8217;ve posted a clarification of my question there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oran</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-12432</link>
		<dc:creator>Oran</dc:creator>
		<pubDate>Thu, 13 Dec 2007 20:43:38 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-12432</guid>
		<description>I have replied to part of this discussion here: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2551436&amp;SiteID=1</description>
		<content:encoded><![CDATA[<p>I have replied to part of this discussion here: <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2551436&amp;SiteID=1" rel="nofollow">http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2551436&amp;SiteID=1</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Cavnar-Johnson</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-12419</link>
		<dc:creator>John Cavnar-Johnson</dc:creator>
		<pubDate>Thu, 13 Dec 2007 17:09:38 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-12419</guid>
		<description>Just one last comment to clarify my previous statement. I wasn&#039;t advocating coding a solution based on mutexes, etc. I was advocating comparing a single-threaded solution to your proposed solution. A single threaded solution is the simplest to code and your proposal is only trivially more complex. I have no doubt that your proposed solution is the best multi-threaded way to achieve the goal. I&#039;m just not convinced that it is better in all circumstances than a single thread solution.</description>
		<content:encoded><![CDATA[<p>Just one last comment to clarify my previous statement. I wasn&#8217;t advocating coding a solution based on mutexes, etc. I was advocating comparing a single-threaded solution to your proposed solution. A single threaded solution is the simplest to code and your proposal is only trivially more complex. I have no doubt that your proposed solution is the best multi-threaded way to achieve the goal. I&#8217;m just not convinced that it is better in all circumstances than a single thread solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-12365</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Wed, 12 Dec 2007 17:50:43 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-12365</guid>
		<description>I&#039;m not sure that both solutions are just as easy to code. 

One uses the same mechanisms as all other message handlers, is thread-safe without doing anything special, etc. 

The other requires using different mechanisms (mutex, reader-writer lock, etc), is thread-safe based on belief (&quot;hasn&#039;t dead locked yet&quot;), and more difficult to test (mocking out the threading libraries).

I will agree that testing the comparative performance would make sense given that you had both solutions implemented, tested, and thread safe.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure that both solutions are just as easy to code. </p>
<p>One uses the same mechanisms as all other message handlers, is thread-safe without doing anything special, etc. </p>
<p>The other requires using different mechanisms (mutex, reader-writer lock, etc), is thread-safe based on belief (&#8221;hasn&#8217;t dead locked yet&#8221;), and more difficult to test (mocking out the threading libraries).</p>
<p>I will agree that testing the comparative performance would make sense given that you had both solutions implemented, tested, and thread safe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Cavnar-Johnson</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-12321</link>
		<dc:creator>John Cavnar-Johnson</dc:creator>
		<pubDate>Tue, 11 Dec 2007 21:17:03 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-12321</guid>
		<description>Yes, much clearer. As I understand it, he needs to process Message A before Message B. He ensured that Message A made it to the queue before Message B and discovered that still wasn&#039;t good enough. You&#039;re saying don&#039;t worry about the order of message arrival. The only thing you need to do is have the thread that processes Message B check the database to make sure that Message A has been processed, and if not, put Message B back on the queue.

I&#039;ll make two observations about this. First, your solution (as I understand it now) is logically an implementation of a simple mutex. Granted, it&#039;s mostly free, but still you&#039;re coordinating the work of two threads accessing a shared resource. Second, the answer to the question of whether your proposed solution offers better throughput/performance  (in a way that matters to the system&#039;s users) than a single threaded solution will be dependent on the particular circumstances of the system. Fortunately, in most situations, that is an easily testable question. Both solutions are easy to code, so I would encourage folks faced with this question to test both solutions thoroughly.</description>
		<content:encoded><![CDATA[<p>Yes, much clearer. As I understand it, he needs to process Message A before Message B. He ensured that Message A made it to the queue before Message B and discovered that still wasn&#8217;t good enough. You&#8217;re saying don&#8217;t worry about the order of message arrival. The only thing you need to do is have the thread that processes Message B check the database to make sure that Message A has been processed, and if not, put Message B back on the queue.</p>
<p>I&#8217;ll make two observations about this. First, your solution (as I understand it now) is logically an implementation of a simple mutex. Granted, it&#8217;s mostly free, but still you&#8217;re coordinating the work of two threads accessing a shared resource. Second, the answer to the question of whether your proposed solution offers better throughput/performance  (in a way that matters to the system&#8217;s users) than a single threaded solution will be dependent on the particular circumstances of the system. Fortunately, in most situations, that is an easily testable question. Both solutions are easy to code, so I would encourage folks faced with this question to test both solutions thoroughly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: udidahan</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-12269</link>
		<dc:creator>udidahan</dc:creator>
		<pubDate>Mon, 10 Dec 2007 22:50:15 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-12269</guid>
		<description>John,

I don&#039;t think he was saying &quot;that doing something quickly is more desirable than doing it correctly&quot;. Exactly the opposite. He seems to be decreasing performance elsewhere to make sure that the messages enter the queue in the correct order.

On your second statement, &quot;he has a requirement to process some messages sequentially&quot;, that was my understanding as well. I also understand that there is some application specific identifier that exists in both messages - the policy Id.

While I agree that employing a “single thread per queue” would work, I consider the decrease in performance/throughput to be unnecessary. I think that we can both agree that going to a threading-primitives solution would most likely result in either deadlocks or data races making it an unviable solution.

My solution is based on the message handler for message B checking if the requisite data for the policy Id is already in the DB. If not, it would call &quot;HandleCurrentMessageLater&quot;, effectively not processing that message. The transactional isolation provided by the DB would prevent the message handler of message B from seeing any interim work being performed by the handler of message A.

I can see that without a policy Id in both messages my solution wouldn&#039;t work. However, I think that it is a reasonable assumption to make given the scenario.

So, it&#039;s not that I&#039;m telling him &quot;that meeting his requirement is too much trouble&quot;, but rather that maybe he&#039;s paying too much for a requirement that, in my opinion, provides very little value.

Does that make things clearer?</description>
		<content:encoded><![CDATA[<p>John,</p>
<p>I don&#8217;t think he was saying &#8220;that doing something quickly is more desirable than doing it correctly&#8221;. Exactly the opposite. He seems to be decreasing performance elsewhere to make sure that the messages enter the queue in the correct order.</p>
<p>On your second statement, &#8220;he has a requirement to process some messages sequentially&#8221;, that was my understanding as well. I also understand that there is some application specific identifier that exists in both messages &#8211; the policy Id.</p>
<p>While I agree that employing a “single thread per queue” would work, I consider the decrease in performance/throughput to be unnecessary. I think that we can both agree that going to a threading-primitives solution would most likely result in either deadlocks or data races making it an unviable solution.</p>
<p>My solution is based on the message handler for message B checking if the requisite data for the policy Id is already in the DB. If not, it would call &#8220;HandleCurrentMessageLater&#8221;, effectively not processing that message. The transactional isolation provided by the DB would prevent the message handler of message B from seeing any interim work being performed by the handler of message A.</p>
<p>I can see that without a policy Id in both messages my solution wouldn&#8217;t work. However, I think that it is a reasonable assumption to make given the scenario.</p>
<p>So, it&#8217;s not that I&#8217;m telling him &#8220;that meeting his requirement is too much trouble&#8221;, but rather that maybe he&#8217;s paying too much for a requirement that, in my opinion, provides very little value.</p>
<p>Does that make things clearer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Cavnar-Johnson</title>
		<link>http://www.udidahan.com/2007/12/09/in-order-messaging-a-myth/comment-page-1/#comment-12253</link>
		<dc:creator>John Cavnar-Johnson</dc:creator>
		<pubDate>Mon, 10 Dec 2007 16:51:27 +0000</pubDate>
		<guid isPermaLink="false">http://udidahan.weblogs.us/2007/12/09/in-order-messaging-a-myth/#comment-12253</guid>
		<description>I&#039;m a little confused by your correspondent&#039;s message and your response. He seems to be saying, in effect, that doing something quickly is more desirable than doing it correctly. Your response seems to miss the point entirely. He wasn&#039;t asking about messages arriving out of order or getting lost. In his situation, I don&#039;t understand how &quot;this.bus.HandleCurrentMessageLater();&quot; can help him since the thread processing the &quot;Policy Approved&quot; message has no way of knowing when to use it. I certainly don&#039;t think just telling him that meeting his requirement is too much trouble is very helpful.

As I understand it, he has a requirement to process some messages sequentially. That is, he must finish processing Message A before He can finish processing Message B. I&#039;m not completely clear on whether or not he should even start processing B before Message A 
is done, but I&#039;m guessing that true sequencing is the requirement.

The most straightforward way to meet this requirement is &quot;single thread per queue&quot;. Often, this is only realistic if you can separate the sequenced messages on to their own queue. If you can&#039;t do that, you have have a big problem and the appropriate solution is highly dependent on the particulars of your situation. The job of the threads handling the sequenced messages gets complicated very quickly. Generally, you will find that you have to use a durable implementation of one or more of the traditional threading primitives (e.g. lock, semaphore, mutex, etc.). Every time I&#039;ve done this, I&#039;ve found that I can more easily create a single threaded solution that performs acceptably than I can design a reliable multi-threaded solution. Of course, that may say more about my limitations as a programmer than anything else (and that&#039;s not meant as sarcasm, I know lots of folks who are better at multithreaded programming than I am).</description>
		<content:encoded><![CDATA[<p>I&#8217;m a little confused by your correspondent&#8217;s message and your response. He seems to be saying, in effect, that doing something quickly is more desirable than doing it correctly. Your response seems to miss the point entirely. He wasn&#8217;t asking about messages arriving out of order or getting lost. In his situation, I don&#8217;t understand how &#8220;this.bus.HandleCurrentMessageLater();&#8221; can help him since the thread processing the &#8220;Policy Approved&#8221; message has no way of knowing when to use it. I certainly don&#8217;t think just telling him that meeting his requirement is too much trouble is very helpful.</p>
<p>As I understand it, he has a requirement to process some messages sequentially. That is, he must finish processing Message A before He can finish processing Message B. I&#8217;m not completely clear on whether or not he should even start processing B before Message A<br />
is done, but I&#8217;m guessing that true sequencing is the requirement.</p>
<p>The most straightforward way to meet this requirement is &#8220;single thread per queue&#8221;. Often, this is only realistic if you can separate the sequenced messages on to their own queue. If you can&#8217;t do that, you have have a big problem and the appropriate solution is highly dependent on the particulars of your situation. The job of the threads handling the sequenced messages gets complicated very quickly. Generally, you will find that you have to use a durable implementation of one or more of the traditional threading primitives (e.g. lock, semaphore, mutex, etc.). Every time I&#8217;ve done this, I&#8217;ve found that I can more easily create a single threaded solution that performs acceptably than I can design a reliable multi-threaded solution. Of course, that may say more about my limitations as a programmer than anything else (and that&#8217;s not meant as sarcasm, I know lots of folks who are better at multithreaded programming than I am).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
