<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Latest Posts</title>
		<link>http://www.xump.org</link>
		<description></description>
				<copyright></copyright>
		<lastBuildDate>Mon, 06 Feb 2012 20:46:01 +0000</lastBuildDate>
		
					<item>
				<guid>http://www.xump.org/blog:2009-06-15</guid>
				<title>2009-06-15</title>
				<link>http://www.xump.org/blog:2009-06-15</link>
				<description>

&lt;p&gt;Have started to reconstruct the engine API, it&#039;s looking nicer. The methods for handling stores and queues now look like this (commit 8c3f97b):&lt;/p&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Tue, 16 Jun 2009 08:24:48 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <p>Have started to reconstruct the engine API, it's looking nicer. The methods for handling stores and queues now look like this (commit 8c3f97b):</p> <ul> <li>store_ref = xump_store_create (engine, store_type, store_name);</li> <li>store_ref = xump_store_fetch (engine, store_name);</li> <li>xump_store_delete (engine, store_name);</li> <li>queue_ref = xump_queue_create (engine, store_name, queue_name);</li> <li>queue_ref = xump_queue_fetch (engine, queue_name);</li> <li>xump_queue_delete (engine, queue_name);</li> </ul> <p>So that the queue refers to its store by name, rather than by reference.</p> <p>For the store portals, I've used the factory feature of IPR portals, which lets us create store instances more simply. At startup we create a factory (also a portal) for each store implementation:</p> <div class="code"> <pre> <code>// Create new engine instance engine = xump_new (); // Create portal factory for each store implementation store = xump_store_ram__xump_store_factory (&quot;RAM&quot;); xump__xump_store_bind (engine, store); xump_store_unlink (&amp;store);</code> </pre></div> <p>We can then create new store instances by using the factory name as a 'store type', e.g:</p> <div class="code"> <pre> <code>store = xump_store_create (engine, &quot;RAM&quot;, &quot;store-1&quot;);</code> </pre></div> <p>The actual work of finding the right factory and getting it to create a new store instance is done in the xump_store_create method.</p> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-06-14</guid>
				<title>2009-06-14</title>
				<link>http://www.xump.org/blog:2009-06-14</link>
				<description>

&lt;h3&gt;&lt;span&gt;Internal accounting&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Tue, 16 Jun 2009 08:24:28 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <h3><span>Internal accounting</span></h3> <p>I've not made the engine API yet, still working through some design concepts. Let's look at credit-based flow control. This is needed to make MOVE work safely. As I've said previously, for COPYs I don't want to use credit-based flow control, indeed any kind of flow control at all.</p> <p>I'll define a &quot;credit&quot; unit, so we can say that one credit corresponds to one message. In AMQP I originally designed credit based on message volume as well but this is nasty because the semantics of credit are fundamentally not about network capacity but rather about how much the upstream trusts the downstream. We cannot trust a recipient with fractions of a message. (This is also why I think COPY does not need credits, because it does not imply any kind of trust relationship.)</p> <p>As messages move down the directed graph of queues, credits move up the graph. Let's look at a typical scenario:</p> <ul> <li>We have a queue with two selectors that each move messages to respective external destinations.</li> <li>Each selector starts with one credit.</li> <li>Two messages arrive, and are passed respectively to each selector.</li> <li>Each selector moves the message it receives to its destination.</li> <li>Each selector now has a credit of zero.</li> <li>A new message arrives in the queue, and waits there, since there are no available selectors.</li> <li>One of the destinations sends an acknowledgment, which is passed to its selector as a credit.</li> <li>That selector is now able to process one more message.</li> </ul> <p>To some extent credits and acknowledgements are the same concept, and we might use &quot;credit&quot; everywhere, especially since it's easier to spell. Thus applications send messages to queues, and credits to selectors.</p> <p>Providing a credit to a selector is in effect paying for a message, and credits are like an internal currency. It makes sense that we aim to balance the books. When a queue is itself fed by one or more MOVE selectors, and it receives credits from a selector, it must pass these credits to its parent MOVE selector(s) in turn, i.e. pay for the messages that it received.</p> <p>Selectors can, at any point, have outstanding messages. That is, they may have one or more messages they provided to a destination but did not yet receive payment for. If the selector is then deleted, it must return its outstanding messages to its source queue. These messages can then be routed to other selectors, or bounced.</p> <h3><span>Queue size limits</span></h3> <p>It makes sense in several scenarios to set a limit on the size of a queue. In fact there are two possible limits:</p> <ul> <li>On the number of unprocessed messages;</li> <li>On the history of processed messages.</li> </ul> <p>When the history gets too large, there is only one sensible strategy, namely to discard the oldest messages. We can hardcode this, there is no need to allow for alternative strategies.</p> <p>When the unprocessed size gets too large, the sensible strategy is to reject the new message as an exception. Discarding the message is an acceptable default (presumably the sender will realize, eventually, and retry or complain).</p> <h3><span>Message exceptions</span></h3> <p>There are several situations where a queue may find itself with a troublesome message that it has to deal with:</p> <ul> <li>When a queue has reached its limit of unprocessed messages;</li> <li>When a queue does not have any active selector that can accept a message.</li> </ul> <p>Dropping the message is a good default action but in cases where it matters, we want to send the message to someone who knows how to handle it. That is often, but not always, the original sender. In AMQP we discussed this question extensively and the best design we came up with (which is not in the current protocol draft, which has taken a left turn to the Moon) was to route the message on a &quot;return address&quot;.</p> <p>Pushing the message forwards on an alternative route rather than returning it to the original source is as far as I can tell more robust and useful. It does not require us to track the message's routing path. It does not require that the source still exists. It lets us centralize exception handling for critical queues. And it lets us handle exceptions with the same mechanisms as deliveries.</p> <p>When exactly is a message &quot;unroutable&quot;? It depends, but these are the cases I know of:</p> <ol> <li>When a message arrives in a queue that has no selectors. E.g. if I send a document to a print queue that has no printers attached to it.</li> <li>When a message arrives in a queue that has no matching selectors. E.g. if I send a document that requires color printing to a queue that has only black and white printers.</li> </ol> <p>In the case when a queue has selectors but they are all busy (i.e. don't have the credit to accept a new message), we can't tell if the message would be routed or not and it does not make much sense to treat it as an exception, yet.</p> <p>The very simplest way to handle exceptions is to move the affected messages to a 'dead-letter' queue, that is defined on a per-queue basis. On the dead-letter queue we can put selectors that route exceptions however we like. To make this work properly, we might want to mangle the message envelope so that the return address, if specified, is used as the address, and the original address is saved somewhere. This is a familiar pattern from the real world.</p> <p>So here is a sketch for exception handling on queues:</p> <ul> <li>By default, if there are no (ready) selectors, hold the message as unprocessed.</li> <li>By default, if the unprocessed size exceeds a per-queue limit, discard new messages (and log some error).</li> <li>By default, if there are selectors but none match, discard the message.</li> <li>Add a BOUNCE operation that is like MOVE, but mangles the address and return addresses.</li> <li>Allow a &quot;default selector&quot; that is invoked if no other selectors match.</li> <li>Allow an &quot;overflow selector&quot; that is invoked if the unprocessed size hits a limit.</li> </ul> <p>When applications try to publish messages to non-existent queues, we can bounce those messages to some per-engine dead-letter queue. This, when used with self-destructive queues, lets us implement a service lookup test.</p> <h3><span>Self-destructive queues</span></h3> <p>A pattern that has been very useful in AMQP and elsewhere is the &quot;self-destructive queue&quot;. This is a queue that deletes itself when its last selector is deleted. Self-destructive queues are typically used for Wolfpack scenarios.</p> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-06-12</guid>
				<title>2009-06-12</title>
				<link>http://www.xump.org/blog:2009-06-12</link>
				<description>

&lt;p&gt;We now have basic APIs for queue, messages, and selectors, implemented in the respective classes. These are simple wrappers, e.g. this is the xump_queue_fetch method:&lt;/p&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Tue, 16 Jun 2009 08:23:52 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <p>We now have basic APIs for queue, messages, and selectors, implemented in the respective classes. These are simple wrappers, e.g. this is the xump_queue_fetch method:</p> <div class="code"> <pre> <code>&lt;method name = &quot;fetch&quot; return = &quot;self&quot;&gt; &lt;doc&gt; This public method fetches a queue from the store. It acts as a constructor and returns a new queue object when successful. The caller must unlink this queue object when finished using it. &lt;/doc&gt; &lt;argument name = &quot;store&quot; type = &quot;xump_store_t *&quot;&gt;Enclosing store&lt;/argument&gt; &lt;argument name = &quot;name&quot; type = &quot;char *&quot;&gt;Queue name, if any&lt;/argument&gt; &lt;declare name = &quot;self&quot; type = &quot;$(selftype) *&quot; /&gt; // xump_store_request_queue_fetch (store, &amp;self, name); &lt;/method&gt;</code> </pre></div> <p>It's basically just a wrapper around the portal method. Now, the problem with these basic APIs is that they don't add enough value. For example, when we fetch a queue, it would be nicer to not have to know the store in advance. Queue names need to be globally unique, so that selector destinations make sense. This uniqueness should be managed by the API, so the caller code cannot get it wrong. Thus, the API has to sit <em>above</em> all the stores.</p> <p>We already implemented a simple queue name cache that lets us work with queues as global objects within an engine instance, and I'll use this as the basis for a new engine-level API. The general model will be:</p> <ul> <li>The create and fetch methods will be implemented at the engine level, in the xump class. This makes it possible to work at the engine global level. We'll put delete at the engine level as well, for consistency.</li> <li>Access to object properties will be via object methods.</li> <li>Other methods, such as adding credit to a selector, will be done at the object level.</li> </ul> <p>Starting with stores, we want to be able to create stores by name. This should be idempotent, so that they do not depend on a precise agreed engine state. E.g. creating a database-backed store should work if the store already exists.</p> <p>Next, queues. These are global within an engine instance. That is, the caller can work with queues without having to specify what store they are in. The engine must manage this. It's only when we create a queue that we need to specify a store, and it makes sense to allow a default here. Another option would be to use a naming convention (like a path prefix) but that means it is impossible to reconfigure a queue to use a different store, something that might be useful. A store name as prefix remains an option, which we may come back to later.</p> <p>Then, selectors. As for queues, we already have an API that works but we'll move the methods into the xump engine class as explained. The previous implementation of the selector class referred to the source queue as an object, but it would be cleaner to refer to a queue name.</p> <p>The natural way to get messages out of the network seems to be to define a selector that has no destination queue, or rather, a selector that has an external destination rather than an internal queue destination. The caller will know whether a selector is an exit node or not, when it creates it. We will call this the &quot;terminal&quot; property of the selector. That is, a selector is a terminal when it delivers messages to an external destination rather than an internal queue. When a selector is not a terminal, its destination name must refer to an existing queue.</p> <p>Lastly, messages. It seems clear there are two sets of semantics for messages:</p> <ul> <li>Message flow through queues and selectors.</li> <li>Browsing historic data in queues.</li> </ul> <p>For the first case, we can rely on the fact that the engine is a closed system. That is, all output is driven by input. If there are no inputs to the system, there will be no outputs either. In a synchronous model, the calling application thus gives an incoming message or acknowledgment to the engine, and in return gets a set (zero or more) deliverable messages, which it can process in a loop.</p> <p>In an asynchronous model, the processing of messages can take an arbitrary time and the caller would not want to wait. So, we'd want to work with callbacks (e.g. asynchronous portal reply methods).</p> <p>For now, we'll design both the engine and the calling application as synchronous and single-threaded, so the API will provide methods to accept incoming messages and acknowledgments, and will provide a list of outgoing messages that the caller can process. Each &quot;publish&quot; pushes messages through the network until all routing is complete, and zero or more &quot;deliveries&quot; are push to that outgoing queue.</p> <p>For the case of historic data, there are two use cases I can see. One is to scroll back and forwards through the history of a queue, a page of messages at a time: &quot;get me the 50 previous messages&quot;. It matches an end-user's browsing of a queue. The semantics are classic: oldest, latest, previous, next. The second use case is to catch up with historic data since a particular time: &quot;give me everything since 9.00am&quot;. In both cases, it only makes sense insofar as the queue in question has historic data, which depends on how it was configured and what selectors have done to it.</p> <p>In earlier sketches of Xump I used the notion of &quot;cursors&quot; but I'm discarding this concept, it appears to be both unnecessary and unhelpful. It seems easier to create a new selector when we want to read historic data on a queue.</p> <p>The simplest form of a queue is an ordered list of messages stretching from tail (newest mesage) to head (oldest message). New published messages are attached before the tail. Messages are taken off the list from the head:</p> <p>[[code]]<br /> Tail Head<br /> | |<br /> [M]<span style="text-decoration: line-through;">[M]</span>[M]<span style="text-decoration: line-through;">[M]<br /> &lt;</span>Unprocessed &#8212;&gt;<br /> [[code]]</p> <p>Actual queue implementations depend on the storage layer. To implement COPY, we need to divide the queue into two sections:</p> <p>[[code]]<br /> Tail Current Head<br /> | | |<br /> [M]<span style="text-decoration: line-through;">[M]</span>[M]<span style="text-decoration: line-through;">[M]</span>[M]<span style="text-decoration: line-through;">[M]</span>[M]<span style="text-decoration: line-through;">[M]<br /> &lt;</span>Unprocessed <span style="text-decoration: line-through;">&gt; &lt;</span> Historical &#8212;&gt;<br /> [[code]]</p> <p>When we create a selector we can thus specify where the selector starts:</p> <ul> <li>At the current position, which is the normal and default choice;</li> <li>At the head, i.e. the oldest message</li> <li>At any position between the current and the head.</li> </ul> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-06-09</guid>
				<title>2009-06-09</title>
				<link>http://www.xump.org/blog:2009-06-09</link>
				<description>

&lt;p&gt;The basics of the storage layer are now in place. I&#039;ll extend this by adding more classes to it, and more implementations. But first, let&#039;s start on the routing layer. My aim is to get an end-to-end demonstration working, with null (fanout) routing.&lt;/p&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Tue, 16 Jun 2009 08:23:20 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <p>The basics of the storage layer are now in place. I'll extend this by adding more classes to it, and more implementations. But first, let's start on the routing layer. My aim is to get an end-to-end demonstration working, with null (fanout) routing.</p> <p>There has been discussion in the AMQP workgroup of exchanges, and their role. In Xump's design, there is an exchange but it is universal and invisible, and is in fact the Xump instance. While AMQP extends routing functionality by defining new exchange types, Xump extends routing functionality by defining new extensions to the single routing layer. We'll do that using a portal API as we did for the storage layer, but this will come later.</p> <p>Xump uses a inverted database analogy for routing. The caller defines <em>selectors</em> on queues, and as data flows through a queue, the routing layer applies the selectors on that queue. This is conceptually simple but harder to make than to explain. In AMQP land, some routing entities (exchanges) have no storage, while others (shared queues) do. I don't like the distinction. It should depend on the selectors and the network they feed: if the queue can empty itself immediately, it does so. And if not, it builds up and empties when it can.</p> <p>So, we are going to design selectors. I'd also thought of calling these <em>triggers</em>, which is a neat abuse of database jargon, but I think it would be inaccurate. Yes, they are triggered by message flow, but they perform a selection action.</p> <p>Selectors specify <em>matching</em> and/or <em>filtering</em> relationships between queues. Matching and filtering are two different and complementary ways of deciding whether a message M should go to queue Q or not:</p> <ul> <li>Matching is complex: every possible address A has a list of selectors that specified it. We thus match a message's address with its correspondong set of selectors, giving a &quot;yes&quot; decision for each of them.</li> <li>Filtering is simple: a selector S inspects a message M and makes a yes/no decision about whether or not it wants that message.</li> </ul> <p>The tradeoffs are:</p> <ul> <li>Matching is a fast O(logn) operation but requires that the set of possible addresses is finite and changes slowly.</li> <li>Filtering works on any aspect of the message, or external conditions, but is a slow O(n2) operation.</li> </ul> <p>Typically, filtering is good for content-based routing, while matching is ideal for topic distribution where the topic tree is finite and slow to change (like stock indices, newsgroup trees, etc.) The ideal combination is to match first, and then filter on the much smaller set of matched messages.</p> <p>When a new message arrives in a queue, we match it against all selectors, giving us an interim hit set. We then filter against each selector in the hit set, giving us a final hit set. Each selector specifies either COPY or MOVE. We do all the COPYs first, and then we do the first MOVE. When we do a MOVE, we push that selector to the end of the list of selectors, so that messages will be round-robined between all MOVE selectors, if there are several.</p> <p>In order to move a message, a selector needs sufficient credit. It gets credit from the destination queue, which tells it, &quot;ready to accept N more messages&quot;. There are two common cases: infinite credit, where messages are delivered without any response from the destination, and single-step, where messages are moved one at a time, with confirmation for each message from the destination.</p> <p>So, if a queue has selectors but none have sufficient credit, messages will accumulate. When any of the selectors receive credit, they will start to move messages again.</p> <p>We could use credit COPY as well but this has some unpleasant side effects. First, it causes source queues to fill up when destinations are slow in processing messages. Second, it forces us to treat selectors as independent cursors on the queue, which makes O(logn) routing impossible or at least very difficult. And it does not appear to be necessary for the use-cases we see: COPY is typically used for high-volume parrot (pub-sub) patterns where messages are never acknowledged, and where messages are pushed towards the destination as rapidly as possible, and dropped when that cannot be done, rather than backing-up source queues.</p> <p>A selector specifies a <em>source</em> queue and a <em>destination</em> (presumably a queue). I'm not yet sure whether the destination is required, i.e. whether selectors are the terminators in the directed network, or whether queues are.</p> <p>For our initial end-to-end proof, we can ignore filtering. The only natural identification for a selector is the selector itself, i.e. the concatenation of its main properties. This is not easy to work with. So, we'll number selectors per source queue and provide a way for applications to fetch selectors by index, exactly as we do for messages.</p> <p>A selector therefore defines some or all of:</p> <ul> <li>A numeric identifier.</li> <li>A source queue.</li> <li>A destination name.</li> <li>A match type, which defines the selector algorithm. I'll list a few below.</li> <li>A match argument, which is passed to the algorithm. Its meaning depends on the match type.</li> <li>An operation, which is one of MOVE or COPY.</li> <li>A credit, which is an integer number of messages. For &quot;infinite&quot; we'll use -1.</li> </ul> <p>Selectors exist in the storage layer, attached to their source queue. It seems to make sense to hold these in the same storage layer instance as their source queue, since their lifespans are linked. If we delete a queue, we delete all selectors attached to it.</p> <p>We need some mechanism to determine whether a name refers to queue, or not, and what storage layer instance that queue is in. The simplest is probably a queue name cache in the Xump engine.</p> <p>For now, we'll define only two match types, &quot;EQ&quot;, which does a literal string comparison between the message address and the argument, and the empty match type, which means &quot;all messages&quot;. These correspond to the AMQP &quot;direct&quot; and &quot;fanout&quot; exchange types.</p> <p>From the above, we need to make:</p> <ul> <li>A queue name cache that holds the set of all known queues and that can interrogate storage layers to know whether a queue is defined or not.</li> <li>A xump_selector class that lets us work with selector objects held in the storage layer. This would work similarly to xump_message.</li> <li>New methods in the store API to handle selectors (create, fetch, delete).</li> <li>Implementation of these methods in the RAM store.</li> </ul> <p>This still won't let us do message routing, but we're getting closer.</p> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-06-08</guid>
				<title>2009-06-08</title>
				<link>http://www.xump.org/blog:2009-06-08</link>
				<description>

&lt;h2&gt;&lt;span&gt;2009-06-08&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Mon, 08 Jun 2009 18:14:21 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <h2><span>2009-06-08</span></h2> <p>I'm removing the message_update method, it does not make sense. We define a message fully when we create it, and all state needed to do routing should be held in the routing layer, not the storage layer.</p> <p>The message_delete method needs to be idempotent, thus safe to call no matter what the state of the store. Thus, before we delete the ram message we need to check that the queue exists. We should be robust against stupid things like fetching a message, deleting the queue, then trying to delete the message. That means we do not need to worry about the order of a teardown. The cost is an extra lookup, eventually this can be optimised away.</p> <p>Message properties (fields): we do not need to manipulate these as objects; they are created and used but never (or rarely) modified for existing messages. Thus, the fastest and simplest data structure will be an env-type block (name=value&lt;nul&gt;&#8230;)</p> <p>To implement message properties, I'm going to call these &quot;headers&quot;, to match the SMTP/HTTP semantics. Headers are name/value pairs, where both name and value are C strings (i.e. they cannot contain null characters). We need to be able to store the headers for a message when we create a new message, and we need to be able to access (but rarely modify) the headers for an existing message.</p> <p>To implement this, we'll make a new xump_headers class that handles header fields. A xump_message will contain a xump_headers object (or at least opportunistically, since there is no point creating xump_header objects we don't need). Here is the test code for xump_headers:</p> <div class="code"> <pre> <code>xump_headers_t *headers; headers = xump_headers_new (); xump_headers_set (headers, &quot;a&quot;, &quot;one&quot;); xump_headers_set (headers, &quot;b&quot;, &quot;two&quot;); xump_headers_set (headers, &quot;c&quot;, &quot;three&quot;); xump_headers_set (headers, &quot;a&quot;, &quot;value&quot;); assert (streq (xump_headers_get (headers, &quot;a&quot;), &quot;value&quot;)); assert (streq (xump_headers_get (headers, &quot;z&quot;), &quot;&quot;)); xump_headers_destroy (&amp;headers);</code> </pre></div> <p>I've used reference counting for the xump_headers class, so that for storage layers that keep the headers in memory, there is no copying. Fetching a message just fetches a reference to the headers. When the last reference is deleted, the headers are also destroyed.</p> <p>We could eventually use the same mechanism to avoid copying message data, by holding it in buckets, which are also reference counted. The break-even point seems to be at about 2,300 bytes, where copying costs more than allocating a bucket using the fastest 'direct' allocator (the ALLOCATOR=direct runtime setting for Base2, which bypasses the memory debugging framework). So in the worst case scenario, we can use buckets for messages of 2.3K and above. But if we assume each message is read at least once, then the break-even point is lower. Using buckets will also eliminate duplicate message content for messages that are on more than one queue (at least, for RAM-based queues).</p> <p>We'll come back to buckets another time, using them to reduce copying work for messages of 1K and above in size. The current API is pretty fast already. Creating and deleting 1M messages takes about 1 second if I switch to the direct allocator. When compiled in release mode, I expect this to go twice as fast.</p> <h2><span>2009-06-06</span></h2> <p>We identify messages using a numeric ID that is unique within a queue. It's the storage layer's responsibility to provide new IDs. We'll use an unsigned 32-bit ID and ignore rollover. If a single queue has more than 2^32 messages, the older ones won't be accessible. Fair enough.</p> <p>Thinking: xump_message and xump_queue objects should have a void * context block which is managed by the storage layer. This requires that the constructors (at least) and destructors are called from within the storage layer. We can constrain destruction of the void * block as icl_mem_free.</p> <h2><span>2009-06-05</span></h2> <p>The API is breaking one of the rules of software design, it's confusing. I find myself looking at the code to figure out where I put the message creation code. This ain't good. So, I'm going to change this again, so that we create messages like we do queues, with a 'message_create' method. This is then a 'create' method on the xump_message class, which invokes the storage portal method 'message_create'.</p> <p>So what we have is:</p> <ul> <li>xump_queue.icl: create, fetch, delete (no update possible on queues).</li> <li>xump_message.icl: create, fetch, update, delete.</li> <li>xump_store.icl: queue_create, queue_fetch, queue_delete, message_create, message_fetch, message_update, message_delete.</li> </ul> <p>Sorry for the detour. Sometimes we need to try stuff in order to realize that it's silly.</p> <h2><span>2009-06-04</span></h2> <p>The storage layer must be entirely ignorant of how messages flow into queues, and out again. This is handled by the engine. What the storage layer does is store messages, provide access to them, and delete them. In our current design, the head of the queue is stable insofar as the only party removing messages is the engine itself.</p> <p>Access to messages is thus synchronous, i.e. the engine polls the storage layer when it needs messages. This means that we can browse queues using an index that iterates from the head of the queue, i.e. 0 = oldest message, 1 = second oldest, etc. We need methods like this, as we previously sketched:</p> <ul> <li>message_fetch (message, index) - fetch message object by index</li> <li>message_update (message) - update message from object</li> <li>message_delete (message) - delete message</li> </ul> <p>Perhaps the best identifier for a message is a queue-unique id, rather than the index. Thus the engine can manipulate messages independently. In storage layers where the real message is large (e.g. a disk file), the message object acts as a reference. In storage layers where the real message is small, the message object would hold the denormalized body data.</p> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-06-03</guid>
				<title>2009-06-03</title>
				<link>http://www.xump.org/blog:2009-06-03</link>
				<description>

&lt;h3&gt;&lt;span&gt;Commit 231aeeb: Making the queue API work nicely&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Wed, 03 Jun 2009 16:37:11 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <h3><span>Commit 231aeeb: Making the queue API work nicely</span></h3> <p>Having prototyped the queue API, it looks clumsy. We'll make these improvements:</p> <ul> <li>Make the create and fetch methods work like constructors, returning a reference to a newly created object, if successful.</li> <li>Use link counting on the xump_queue object, so we can use unlink instead of destroy. This is nice because if we don't use new, we should not use destroy either.</li> <li>Scrap the update method, since this does nothing useful. We can add it back if needed but for now it looks like queue properties are either established at creation time, or read-only.</li> </ul> <p>So while the portal request API still uses the RESTful model, the xump_queue class layers a more fluid object-oriented API on top of that. This is what the old calling code looked like (from the xump.icl selftest method):</p> <div class="code"> <pre> <code>xump_queue_t *queue; queue = xump_queue_new (store, &quot;Test queue&quot;); xump_queue_create (queue); xump_queue_fetch (queue); xump_queue_update (queue); xump_queue_delete (queue); xump_queue_destroy (&amp;queue);</code> </pre></div> <p>It's clear, but too different from the normal way of working with iCL objects. Having new and create, and delete and destroy is confusing. iCL lets me mark the new and destroy methods as private, so these are not exported to callers. The revised API looks more elegant:</p> <div class="code"> <pre> <code>xump_queue_t *queue = NULL; // Create acts as a constructor queue = xump_queue_create (store, &quot;Test queue&quot;); // Unlink is an soft destructor xump_queue_unlink (&amp;queue); // Fetch also acts as a constructor queue = xump_queue_fetch (store, &quot;Test queue&quot;); // Delete acts as a hard destructor xump_queue_delete (&amp;queue);</code> </pre></div> <h3><span>Commit cee4083: Implemented queue_post method</span></h3> <p>I'm not sure that the message API I sketched yesterday is the right one. In any case, for sticking new messages on queues, it's not right. The model that feels right is:</p> <ul> <li>queue_post (queue, message) - post message to queue</li> </ul> <p>Which fits the RESTful pattern and makes this a method of the storage layer's queue class, which is accurate. The queue is the class that knows how to organize its messages.</p> <p>Here is the test case for posting messages to a queue:</p> <div class="code"> <pre> <code>// Create a queue and post messages to it queue = xump_queue_create (store, NULL); message = xump_message_post (queue, &quot;address1&quot;, &quot;abc&quot;, 4); xump_message_unlink (&amp;message); message = xump_message_post (queue, &quot;address2&quot;, &quot;def&quot;, 4); xump_message_unlink (&amp;message); xump_queue_unlink (&amp;queue);</code> </pre></div> <p>The store_ram implementation is pretty trivial, it'll be more fun making a file system storage layer. Several ways of doing this:</p> <ul> <li>One file per queue, with one message per line. For text messages, especially if messages are never deleted.</li> <li>One directory per queue, with one message per file. For large messages, especially for file-transfer type work. Meta data can be in separate files.</li> <li>One file per store, with queues and messages indexed into the file. Easy management of stores, and very fast if the indexes are properly designed.</li> </ul> <p>Using a database like SQLite would also be fun: one table per queue, one row per message. This would probably be 10x slower than using a custom indexed file.</p> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-06-02</guid>
				<title>2009-06-02</title>
				<link>http://www.xump.org/blog:2009-06-02</link>
				<description>

&lt;p&gt;This single threaded version will let us prototype the APIs. For now, the APIs will be synchronous, that is, the caller requests something, and gets a response when the work has been done. The called object and the calling object occupy the same thread.&lt;/p&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Tue, 02 Jun 2009 13:03:50 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <p>This single threaded version will let us prototype the APIs. For now, the APIs will be synchronous, that is, the caller requests something, and gets a response when the work has been done. The called object and the calling object occupy the same thread.</p> <p>Let's explore the queue-message-field API further. We define this API as portal requests in the xump_store.icl class. Roughly:</p> <ul> <li>queue_create (&amp;queue, name) - create queue in store</li> <li>queue_fetch (&amp;queue, name) - fetch queue object</li> <li>queue_update (queue) - update queue from object</li> <li>queue_delete (queue) - delete queue</li> <li>message_create (&amp;message, queue, address, bucket) - create message in queue</li> <li>message_fetch (&amp;message, index) - fetch message object by index</li> <li>message_update (message) - update message from object</li> <li>message_delete (message) - delete message</li> <li>field_create (&amp;field, message, name, value) - create field in message</li> <li>field_fetch (&amp;field, message, name) - fetch field object</li> <li>field_update (field) - update field from object</li> <li>field_delete (field) - delete field</li> </ul> <p>This mirrors a RESTful model, in which a remote resource (in this case, on the other side of the API call) is managed by doing create/retrieve/update/delete on a representation of that resource (in this case, an object). In a classic OO model, the resource and the object would be the same thing. Here, they are not.</p> <p>The reasons for this not-quite-OO design:</p> <ul> <li>It lets us define resources that have different life cycles than objects, which we need to define persistent resources (that remain alive when the application stops).</li> <li>It lets us do concurrent access to shared resources in a safe fashion.</li> <li>It lets us hide the implementation of the resources from the calling application.</li> </ul> <p>The word &quot;retrieve&quot; is annoying to type, so I'll use &quot;fetch&quot; instead. The more often we use a word, the shorter and simpler it should be.</p> <h3><span>Commit 7e30756: Constructing the portal queue API.</span></h3> <p><a href="http://github.com/pieterh/xump/commit/7e3075696b117992e8b372f2434e1520e7d3b432">Here.</a></p> <p>To make it simple, the engine has a single store instance which is just the 'store' property. This is not a full design. We'd want to make at least one store instance per backend, but in fact allow the caller to create an arbitrary number of store instances, referenced by name. We'll add that later.</p> <p>How this works now - this is from the xump.icl selftest method:</p> <div class="code"> <pre> <code> // Create an engine instance xump_t *xump; xump = xump_new (); // Create a queue object within single store xump_queue_t *queue; queue = xump_queue_new (xump_store (xump), &quot;Test queue&quot;); // Check that every methods fails properly assert (xump_queue_create (queue) == -1); assert (xump_queue_fetch (queue) == -1); assert (xump_queue_update (queue) == -1); assert (xump_queue_delete (queue) == -1); // Destroy queue object and engine instance xump_queue_destroy (&amp;queue); xump_destroy (&amp;xump);</code> </pre></div> <p>Running the create method a billion times takes around 7.5 seconds on a 3GHz core. So, about 130M requests/second, 7.5 nanoseconds per request. No bottleneck here, yet, synchronous portals are fast.</p> <h3><span>Commit 5f06b01: Engine now supports multiple store registration/lookup</span></h3> <p><a href="http://github.com/pieterh/xump/commit/5f06b010f6b422fee491401bfb88f8c514dab381">Here.</a></p> <p>Added two methods to the engine, which let the caller register and lookup stores. It's more sensible that the caller creates the store portal, since it knows what extensions it is using. The API for creating and registering a new store is short and sweet:</p> <div class="code"> <pre> <code>xump_register_store (xump, xump_store_ram__xump_store_new (NULL, storenamegoeshere));</code> </pre></div> <p>I called the methods 'register_store' and 'lookup_store' because the object_verb form I'd usually prefer ('store_register' and 'store_lookup') suggest that these methods are in the store class, which they are not.</p> <h3><span>Commit 9f9a1c2: Improved engine store method names</span></h3> <p><a href="http://github.com/pieterh/xump/commit/9f9a1c29c8ce42a7265c67b20409983400c2c096">Here.</a></p> <p>Actually, on second thoughts, it's even nicer to make the store list look like a property of engine, and use the same style as we use for opaque object properties, namely &quot;set_property&quot; and &quot;property&quot;. This gives us a readable:</p> <div class="code"> <pre> <code>xump_set_store (xump, xump_store_ram__xump_store_new (NULL, &quot;RAM1&quot;)); xump_set_store (xump, xump_store_ram__xump_store_new (NULL, &quot;RAM2&quot;)); assert (xump_store (xump, &quot;RAM1&quot;) != NULL); assert (xump_store (xump, &quot;RAM0&quot;) == NULL);</code> </pre></div> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-06-01</guid>
				<title>2009-06-01</title>
				<link>http://www.xump.org/blog:2009-06-01</link>
				<description>

&lt;p&gt;The xump.icl class provides engine instances. These isolate some stores, not others. A RAM-based store sits inside an engine instance. A disk-based store sits outside the engine instance and can be accessed from any instance. At this stage we don&#039;t do any kind of access control. So our resource hierarchy changes a little:&lt;/p&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Tue, 02 Jun 2009 13:00:36 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <p>The xump.icl class provides engine instances. These isolate some stores, not others. A RAM-based store sits inside an engine instance. A disk-based store sits outside the engine instance and can be accessed from any instance. At this stage we don't do any kind of access control. So our resource hierarchy changes a little:</p> <div class="code"> <pre> <code>Engine +-- Store +-- Queue +-- Message +-- Field</code> </pre></div> <p>Starting on the basic framework for the store portal and plugins. We have these classes:</p> <ul> <li>xump.icl - engine class</li> <li>xump_store.icl - store portal</li> <li>xump_store_ram.icl - RAM based store stub that says hello</li> </ul> <p>All single threaded, so no SMT, no multicore. That makes the classes simpler, but for any kind of performance, or when using disk-based persistence, we'll need multithreading. To be designed later.</p> <p>What the stub RAM store looks like (trimming comments):</p> <div class="code"> <pre> <code>&lt;?xml?&gt; &lt;class name = &quot;xump_store_ram&quot; comment = &quot;Xump RAM store back-end&quot; script = &quot;icl_gen&quot; license = &quot;gpl&quot; opaque = &quot;1&quot; &gt; &lt;inherit class = &quot;xump_store_back&quot; /&gt; &lt;method name = &quot;announce&quot;&gt; icl_console_print (&quot;I: initializing RAM-based storage layer&quot;); &lt;/method&gt; &lt;/class&gt;</code> </pre></div> <p>And this works:</p> <div class="code"> <pre> <code>$ boom build boom I: [Xump]: Generating files... boom I: [Xump]: Building Xump... $ boom test boom I: [Xump]: Running regression tests...</code> </pre></div> <p>This is the first running code. Not much, but it registers and calls a plugin. Committed as change 014a172.</p> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-05-30</guid>
				<title>2009-05-30</title>
				<link>http://www.xump.org/blog:2009-05-30</link>
				<description>

&lt;p&gt;I&#039;m analysing the storage layer, which holds queues and messages in different ways (RAM, file system, SQL database, and so on). My goal is to make a minimal storage layer using the iPR portal system, with two or three different implementations. Then, to test these and get performance measurements. The design for Xump is very roughly this:&lt;/p&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Tue, 02 Jun 2009 13:00:14 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <p>I'm analysing the storage layer, which holds queues and messages in different ways (RAM, file system, SQL database, and so on). My goal is to make a minimal storage layer using the iPR portal system, with two or three different implementations. Then, to test these and get performance measurements. The design for Xump is very roughly this:</p> <div class="code"> <pre> <code>+--------------------------------+ | Application layer | +--------------------------------+ | Routing layer | +--------------------------------+ | Storage layer | +----------+----------+----------+ | Back-end | Back-end | Back-end | +----------+----------+----------+</code> </pre></div> <p>Making it simpler&#8230; what can we ignore for now? Our use case for Xump (which is a social messaging layer above Wikidot) calls for very high volumes of quite small text messages (80-160 characters). We would expect thousands of queues, each containing thousands of messages. We'd want these to be persistent and archived, with messages being held on their queues for as long as the queues existed.</p> <p>We can ignore messages with multipart contents. This is an advanced use case and arguably it is not a good one, since it creates messages that are complex for applications to work with. If my application produces multipart messages, that makes it hard for others to talk to me. So a framework that allows this may actually be helping me to shoot myself in the foot.</p> <p>For high volumes of small messages, copying is not a major concern. We avoid copying by manipulating references, but that is not free. So, we will for now copy data. Later, and for larger messages, we'll see about normalizing data so that copying is reduced when the same message is sent to many consumers.</p> <p>Every single message has an address, which is used heavily, so we will make this a dedicated property of the class. A message also has content body, content length, and a table of name/value fields.</p> <p>Let's build the storage system around queues. That is, a store holds a number of queues, which hold a number of messages. We can interrogate the store for queues and messages, and it will return us memory objects that we can work with.</p> <p>The iPR portal system provides a virtual class interface. Our portal class will be xump_store.icl. This would have implementations (called &quot;portal back-ends&quot;) like xump_store_fs.icl (file system), xump_store_ram.icl, xump_store_sql.icl, and so on. Each portal back-end instance is equal to a store instance, and implements the portal methods. Which we can break into:</p> <ul> <li>Creating and working with queues in a particular store.</li> <li>Creating and working with messages in a particular queue (in its store).</li> </ul> <p>The queues and messages that a store manages are opaque, and invisible as such to the storage layer. To work with a queue, the caller asks the back-end to provide a queue object. It can execute methods on this object (some of which may affect the stored queue). It then destroys the queue object. Messages are handled in the same way.</p> <p>We will use the create-retrieve-update-delete pattern for working with queues and messages. To some extent this mirrors the RESTful pattern for working with remote resources. In this case, the remote resources sit in a store that is opaque to the caller, which accesses it via the portal interface.</p> <p>To repeat in a different way: when the caller does xump_queue_destroy(), this destroys a queue object but does not destroy the queue held in the store.</p> <p>The queue and message objects that the store provides to the calling layer are private, not locked, and not shared (they do not support reference counting).</p> <p>The simplest workable identifiers for queues are names. It makes sense that a store can auto-name private queues. For messages, we can use sequence numbers.</p> <p>The xump_store.icl portal class needs these methods for working with queues:</p> <ul> <li>Create (named or unnamed) queue in store, with given properties.</li> <li>Retrieve queue from store by name.</li> <li>Update queue with given properties.</li> <li>Delete queue from store.</li> </ul> <p>And for working with messages:</p> <ul> <li>Create new message in queue, with given content and address.</li> <li>Retrieve message from queue (there are various patterns here).</li> <li>Update a message with given properties.</li> <li>Delete message from queue.</li> </ul> <p>And finally, to manipulate fields on messages:</p> <ul> <li>Create new field on message, with given name and value.</li> <li>Retrieve field from message, by name.</li> <li>Update field value.</li> <li>Delete field from message.</li> </ul> <p>We then need classes to hold queue, message and field references:</p> <ul> <li>xump_queue.icl, which refers to a queue in a store.</li> <li>xump_message.icl, which refers to a message in a queue.</li> <li>xump_field.icl, which refers to a field in a message.</li> </ul> <p>So our resource hierarchy looks like this:</p> <div class="code"> <pre> <code>Store +-- Queue +-- Message +-- Field</code> </pre></div> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-05-25</guid>
				<title>2009-05-25</title>
				<link>http://www.xump.org/blog:2009-05-25</link>
				<description>

&lt;p&gt;Have added opaque classes to iCL, and released an upgrade of OpenAMQ that uses these in a few places. Opaque classes work fine except for one common case, when they&#039;re used in invasive containers. We could use the neutral containers but they are a lot of extra work in use.&lt;/p&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Tue, 02 Jun 2009 12:59:47 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <p>Have added opaque classes to iCL, and released an upgrade of OpenAMQ that uses these in a few places. Opaque classes work fine except for one common case, when they're used in invasive containers. We could use the neutral containers but they are a lot of extra work in use.</p> <p>Decision: all public classes will be opaque and when we need to make lists or tables of them, we'll use the ipr_looseref_list and ipr_hash classes.</p> <p>So, API classes have this general interface:</p> <p>objref = myclass_new (arguments);<br /> objcopy = myclass_link (objref);<br /> myclass_some_method (objref);<br /> myclass_unlink (&amp;objcopy);</p> <ul> <li>All classes are reference counted.</li> <li>All classes are synchronous.</li> <li>All classes are threadsafe.</li> <li>All classes are opaque.</li> </ul> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.xump.org/blog:2009-05-17</guid>
				<title>2009-05-17</title>
				<link>http://www.xump.org/blog:2009-05-17</link>
				<description>

&lt;p&gt;Xump is meant to become an embeddable messaging engine that solves two recurrent problems (we see in OpenAMQ and Zyre), namely routing and storage. It should do for messaging products what game engines do for video games. Standard tactic for software engineering: make 1 and 2 by hand, then solve N with a general solution.&lt;/p&gt;
&lt;p&gt;by &lt;span class=&quot;printuser avatarhover&quot;&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;&lt;img class=&quot;small&quot; src=&quot;http://www.wikidot.com/avatar.php?userid=99&amp;amp;size=small&amp;amp;timestamp=1328561160&quot; alt=&quot;pieterh&quot; style=&quot;background-image:url(http://www.wikidot.com/userkarma.php?u=99)&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://www.wikidot.com/user:info/pieterh&quot;  &gt;pieterh&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</description>
				<pubDate>Tue, 02 Jun 2009 12:56:59 +0000</pubDate>
												<content:encoded>
					<![CDATA[
						 <p>Xump is meant to become an embeddable messaging engine that solves two recurrent problems (we see in OpenAMQ and Zyre), namely routing and storage. It should do for messaging products what game engines do for video games. Standard tactic for software engineering: make 1 and 2 by hand, then solve N with a general solution.</p> <p>The design of Xump is a mix of ideas collected over the last few years. The engine manages a set of FIFO <em>queues</em>. <em>Messages</em> flow through one or more queues in a directed network of any complexity. Everything is a queue so the whole network is asynchronous. The calling application (that is, the product into which we embed the Xump engine) constructs this network dynamically at runtime, though the network may also be persistent. The lifecycle of all resources is visible to, and managed by, the calling application.</p> <p>Queues pull messages from other queues via <em>selectors</em>, which specify static <em>matching</em> and <em>filtering</em> operations. Selectors are like stored search criteria that act on the head of the queue, eating up or otherwise operating on messages. A selector reads from one queue, and writes to another queue or set of queues. Matching is a O(logn) set operation, in which Xump compares a message address to the set of selectors that read on a queue. Filtering is a O(n2) operation in which Xump compares one message to one selector. In theory we match first, and filter second.</p> <p>Selector match and filter operations are: Move, Copy, and Delete. These work as you would expect. Here is how two applications divide the flow of messages on a queue (the Wolfpack pattern for workload distribution):</p> <div class="code"> <pre> <code>Queue1 -&gt; Selector MOVE -&gt; Queue2 -&gt; Selector MOVE -&gt; Queue3</code> </pre></div> <p>Here is how two applications each get the full flow of messages (the Parrot pattern for information distribution):</p> <div class="code"> <pre> <code>Queue1 -&gt; Selector COPY -&gt; Queue2 -&gt; Selector COPY -&gt; Queue3</code> </pre></div> <p>A mix of selector operations is valid. Here is how two applications divide the work on a queue, while a third gets a copy of every message:</p> <div class="code"> <pre> <code>Queue -&gt; Selector MOVE -&gt; Recipient -&gt; Selector MOVE -&gt; Recipient -&gt; Selector COPY -&gt; Recipient</code> </pre></div> <p>The implementation of selectors is extensible, via a virtual class interface, and the intention is that message processing applications that use Xump would provide their own implementations for the xump_select class.</p> <p>To read messages off a queue, applications (that is, messaging servers which use Xump as their embedded engine) open and close &quot;cursors&quot; on queues. Xump cursors are analogous to the SQL cursor concept. The main difference is that when a cursor is open, messages are sent asynchronously to the application.</p> <p>Applications use Xump by:</p> <ul> <li>Constructing a directed network of queues and selectors;</li> <li>Setting up cursors.</li> <li>Publishing messages to queues.</li> <li>Delivering messages received from cursors.</li> </ul> <p>The persistence layer is extensible, via a virtual class interface, with the intention being that applications which embed Xump would provide their own storage layer implementations. Persistence happens at the queue level, so it is possible to e.g. provide persistent subscriptions for some clients, and transient ones for others.</p> <p>Delivery semantics (e.g. message acknowledgement) affect selectors insofar as selectors may want acknowledgment for their operations, and effectively block until they get it. This would cause the queue to build up, typical for Wolfpack. Without this, typical for Parrot, queues will process messages at full speed and mainly remain empty (unless sheer processing costs caused backlogs).</p> <p>by <span class="printuser avatarhover"><a href="http://www.wikidot.com/user:info/pieterh" ><img class="small" src="http://www.wikidot.com/avatar.php?userid=99&amp;size=small&amp;timestamp=1328561160" alt="pieterh" style="background-image:url(http://www.wikidot.com/userkarma.php?u=99)" /></a><a href="http://www.wikidot.com/user:info/pieterh" >pieterh</a></span></p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>
