<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fubaredness Is Contagious &#187; erlang</title>
	<atom:link href="http://somic.org/category/erlang/feed/" rel="self" type="application/rss+xml" />
	<link>http://somic.org</link>
	<description>Dmitriy Samovskiy's Blog</description>
	<lastBuildDate>Wed, 01 Sep 2010 07:55:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hacking RabbitMQ &#8211; Remote Queue Forwarders</title>
		<link>http://somic.org/2009/12/02/hacking-rabbitmq-remote-queue-forwarders/</link>
		<comments>http://somic.org/2009/12/02/hacking-rabbitmq-remote-queue-forwarders/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 16:59:53 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[rabbitmq]]></category>
		<category><![CDATA[hack]]></category>

		<guid isPermaLink="false">http://somic.org/?p=908</guid>
		<description><![CDATA[Since earlier this year when I got my copy of Erlang book, I&#8217;ve wanted to do something unconventional with RabbitMQ source. I finally came up with an idea, which is somewhat interesting and maybe even useful, and could be done by an Erlang beginner like myself.
Some background first. Each Erlang program in general consists of [...]]]></description>
			<content:encoded><![CDATA[<p>Since earlier this year when I got my copy of Erlang book, I&#8217;ve wanted to do something unconventional with <a href="http://www.rabbitmq.com">RabbitMQ</a> source. I finally came up with an idea, which is somewhat interesting and maybe even useful, and could be done by an Erlang beginner like myself.</p>
<p>Some background first. Each Erlang program in general consists of multiple Erlang processes that send and receive messages to/from each other. These are not your regular processes &#8211; these processes are running inside the Erlang VM, and are not mapped to either processes or threads on the system level in any way. They are cheap to create, and communications between them are fast. Each process has a process ID (pid) associated with it. If multiple Erlang VMs share a cookie (a piece of text which is used as a security token), processes on any Erlang VM can freely talk to each other without any code modification.</p>
<p>RabbitMQ implements each queue as an Erlang process. You can think of AMQP exchanges as pieces of routing logic &#8211; when a message arrives, Rabbit applies the routing rules to its routing key and sends the message to all eligible queues. Since each queue is a process and has a pid, in a nutshell exchanges send the message to several pids.</p>
<p>In non-clustered mode, Rabbit routing function will return a list of local PIDs by selecting values stored in a mnesia table (rabbit_durable_queue and rabbit_queue). But since RabbitMQ can also run in clustered mode, developers already implemented a way to send messages to queues on remote nodes. So when I hacked rabbit_durable_queue and rabbit_queue tables and replaced PIDs pointing to local queues with PIDs pointing to remote queues, I got myself a remote queue forwarder.</p>
<p>How is this useful you might ask. RabbitMQ supports remote queues only in clustered mode. The way clustering is implemented today (using mnesia in distributed mode), it&#8217;s not recommended to run a rabbit cluster over non-LAN links. This is because if 2 rabbit nodes lose and then regain connectivity to each other, the cluster may enter a &#8220;partitioned network&#8221; state, which effectively means that rabbit cluster is not functional (in other words, mnesia sacrifices tolerance to partitioning in order to achieve consistency and availability &#8211; recall CAP theorem). With remote queue forwarding, you don&#8217;t need to set up clustering and hence &#8220;partitioned network&#8221; state won&#8217;t affect you by design &#8211; and that&#8217;s what mattered to me.</p>
<p>On the other hand, remote queue forwarding can potentially break some AMQP guarantees. For example, if a remote node is temporarily unavailable, Rabbit won&#8217;t queue the message for later re-delivery (because such situation is currently impossible in unhacked Rabbit). It means that YOU SHOULD NOT USE THIS HACK UNLESS YOU KNOW WHAT YOU ARE DOING.</p>
<p>The hack works for me though in the following scenario. I publish messages with immediate=true (indicates that payload is time sensitive). Messages are sent to N local queues. These N local queues are forwarded to N remote nodes, with a consumer attached to 127.0.0.1 on each node. In this project, I don&#8217;t rely on any AMQP guarantees &#8211; I discard basic.return commands and can tolerate occasional message not reaching some or even all consumers.</p>
<p>I doubt anyone will find this hack in its current form useful, but just in case I uploaded it to <a href="http://github.com/somic/rabbit_queue_forwarder">http://github.com/somic/rabbit_queue_forwarder</a>.</p>
<p><em>PS. After I started this small project, Tony Garnock-Jones <a href="http://twitter.com/leastfixedpoint/status/5984842386">announced</a> that his work on pluggable exchange types has been added to default branch. I still went ahead and published my post, but please note that pluggable exchange types could probably achieve similar effect more cleanly.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2009/12/02/hacking-rabbitmq-remote-queue-forwarders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Erlang R13B02-1</title>
		<link>http://somic.org/2009/10/21/building-erlang-r13b02-1/</link>
		<comments>http://somic.org/2009/10/21/building-erlang-r13b02-1/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 18:10:46 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[rabbitmq]]></category>

		<guid isPermaLink="false">http://somic.org/?p=885</guid>
		<description><![CDATA[This is a quick note in case anyone is having the same issue.
When building erlang R13B02-1 on a 64bit non-SMP machine (not sure if it matters), &#8220;make -j 2&#8243; somehow resulted in an error which I could not work around. Reverting to simply make (without -j 2) and starting compilation from the very beginning fixed [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick note in case anyone is having the same issue.</p>
<p>When building erlang R13B02-1 on a 64bit non-SMP machine (not sure if it matters), &#8220;make -j 2&#8243; somehow resulted in an error which I could not work around. Reverting to simply make (without -j 2) and starting compilation from the very beginning fixed it.</p>
<p>Also, after final make install, I could not start erl &#8211; it was complaining about &#8220;start.boot not found&#8221;. The solution is to symlink boot files like this:</p>
<p><code style="font-size:12px"><br />
cd /usr/lib/erlang/bin<br />
ln -s /usr/lib/erlang/releases/R13B02/start.boot .<br />
ln -s /usr/lib/erlang/releases/R13B02/start_clean.boot .<br />
ln -s /usr/lib/erlang/releases/R13B02/start_sasl.boot .<br />
</code></p>
<p>I configured it with &#8220;./configure &#8211;prefix=/usr &#8211;disable-x &#8211;enable-threads &#8211;enable-kernel-poll &#8211;disable-hipe&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2009/10/21/building-erlang-r13b02-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling Erlang On Linux With Old Glibc</title>
		<link>http://somic.org/2009/04/14/compiling-erlang-on-linux-with-old-glibc/</link>
		<comments>http://somic.org/2009/04/14/compiling-erlang-on-linux-with-old-glibc/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 14:16:27 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[compile]]></category>

		<guid isPermaLink="false">http://somic.org/?p=535</guid>
		<description><![CDATA[I recently wanted to compile Erlang (in order to install RabbitMQ) on a Linux box with old glibc (2.3.2, from days of Red Hat Linux 7.0). It was the only out-of-date component, everything else was quite fresh &#8211; GCC 4.3.3, binutils 2.19.1.
Version of Erlang I used was R12B-5. I configured it with ./configure &#8211;disable-x &#8211;enable-threads [...]]]></description>
			<content:encoded><![CDATA[<p>I recently wanted to compile Erlang (in order to install <a href="/category/rabbitmq">RabbitMQ</a>) on a Linux box with old glibc (2.3.2, from days of Red Hat Linux 7.0). It was the only out-of-date component, everything else was quite fresh &#8211; GCC 4.3.3, binutils 2.19.1.</p>
<p>Version of Erlang I used was R12B-5. I configured it with ./configure &#8211;disable-x &#8211;enable-threads &#8211;disable-hipe.</p>
<p>But it wouldn&#8217;t build, giving me the following error:</p>
<pre style="font-size:12px">Fatal, could not get clock_monotonic value!, errno = 22</pre>
<p>This was strange because I had no problems building this version of erlang on Debian Etch, even with an older compiler.</p>
<p>The solution was to edit all instances of config.h in the build tree (in my case, there were 2 &#8211; lib/erl_interface/src/i686-pc-linux-gnu/config.h and erts/i686-pc-linux-gnu/config.h) <strong>after running <em>./configure</em> but before starting <em>make</em> </strong>and comment out this line:</p>
<pre style="font-size:12px">/* Define if you want to use clock_gettime to simulate gethrtime */
/* #define GETHRTIME_WITH_CLOCK_GETTIME 1 */</pre>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2009/04/14/compiling-erlang-on-linux-with-old-glibc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>On rabbitmqctl and badrpc,nodedown</title>
		<link>http://somic.org/2009/02/19/on-rabbitmqctl-and-badrpcnodedown/</link>
		<comments>http://somic.org/2009/02/19/on-rabbitmqctl-and-badrpcnodedown/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 16:20:42 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[rabbitmq]]></category>
		<category><![CDATA[badrpc]]></category>
		<category><![CDATA[net_adm]]></category>
		<category><![CDATA[nodedown]]></category>
		<category><![CDATA[rabbitmqctl]]></category>

		<guid isPermaLink="false">http://somic.org/?p=390</guid>
		<description><![CDATA[In the true spirit of open source community that has formed around RabbitMQ in the past several years and continues growing every week, on the mailing list we have recently tackled an issue when one runs &#8220;rabbitmqctl status&#8221; and gets &#8220;badrpc,nodedown&#8221; response, while broker is running as evidenced by ps output. Check out a thread [...]]]></description>
			<content:encoded><![CDATA[<p>In the true spirit of open source community that has formed around <a href="http://www.rabbitmq.com">RabbitMQ</a> in the past several years and continues growing every week, on the mailing list we have recently tackled an issue when one runs &#8220;rabbitmqctl status&#8221; and gets &#8220;badrpc,nodedown&#8221; response, while broker is running as evidenced by <em>ps</em> output. Check out a thread on &#8220;broker runs; cant&#8217; get status&#8221; <a href="http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2009-February/">here</a>. The issue is centered around erlang&#8217;s security and communications mechanism in distributed mode. Here is a tentative step-by-step that can help you resolve the issue.</p>
<p><strong>Are you running broker as user rabbitmq and rabbitmqctl as root or rabbitmq?</strong> If not, please stop and fix this. This is not a requirement per se, but this represents canonical installation of rabbitmq broker. You can certainly hack your scripts to work around this requirement, but you are on your own if you do.</p>
<p><strong>Double check that broker is in fact running.</strong> Use <em>ps</em>, <em>netstat -lptn</em> (look for port 5672 unless you overrode it in <em>/etc/default/rabbitmq</em>). Telnet to localhost on port 5672, type <em>AMQP</em> and press ENTER several times. You should get response that at least will show <em>AMQ</em>. Check logs at /var/log/rabbitmq to verify that broker saw your connection attempt.</p>
<p><strong>Next step is to start &#8220;erl -sname foo -cookie coo&#8221; in shell and run this command: &#8220;net_adm:names().&#8221;</strong></p>
<p>If this command returns <em>ok</em> followed by a list of nodes within 1 or 2 seconds, check if rabbit is there. If it is, it&#8217;s very likely that you have users mixed up above. Please double check. If rabbit node is not listed, double check that rabbit broker is still running.</p>
<p>If this command returns <em>{error,address}</em>, there is a problem with your instance of EPMD, erlang naming daemon (<a href="http://erlang.org/doc/man/net_adm.html">man net_adm</a>). First, check if it&#8217;s running (it most likely *is* running). Then, in erlang, run &#8220;<em>net_adm:localhost().</em>&#8221; Exit erlang, and try to connect to exactly the name you got from <em>net_adm:localhost()</em> on port 4369 (epmd). This shouldn&#8217;t work and should timeout. If it doesn&#8217;t time out, you shouldn&#8217;t have gotten <em>{error,address}</em>.</p>
<p>The problem most likely will be that name as returned by <em>net_adm:localhost()</em> is associated with some IP in <em>/etc/hosts</em> or in DNS which is either not accessible from this host, or firewalled off. An entry in <em>/etc/hosts</em> that associates this name with 127.0.0.1 or one of other IPs on this server should fix the problem.</p>
<p>Alternatively, <em>net_adm:names()</em> may time out with <em>{error, timeout}</em>. <a href="/2008/04/22/snoopy-fubars-erlang/">We have seen it caused by snoopy in the past</a>. Remove snoopy or do not install it system wide in /etc/ld.so.preload, and you should be fine.</p>
<p>If these steps did not help, please leave a comment below or join <a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">rabbitmq-discuss</a> and ask your question there, and we&#8217;ll help!</p>
<p><strong>UPDATE 2009-04-17</strong>: Your host&#8217;s name as shown by net_adm:localhost() does not technically <em>need</em> to be defined in /etc/hosts. But if it&#8217;s not there, it should not be defined anywhere &#8211; when you do &#8220;ping name&#8221;, you should get &#8220;ping: unknown host name&#8221;. I have seen at least one case when it worked this way. This is somewhat unverified though.</p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2009/02/19/on-rabbitmqctl-and-badrpcnodedown/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Snoopy Fubars Erlang</title>
		<link>http://somic.org/2008/04/22/snoopy-fubars-erlang/</link>
		<comments>http://somic.org/2008/04/22/snoopy-fubars-erlang/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 16:56:54 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[rabbitmq]]></category>

		<guid isPermaLink="false">http://somic-org.homelinux.org/blog/2008/04/22/snoopy-fubars-erlang/</guid>
		<description><![CDATA[I just spent roughly 2 days trying to figure out why I could not start a rabbitmq broker on a Debian machine. To make a long story short, it was caused by snoopy. Snoopy fubars erlang. Solution is to remove snoopy (dpkg &#8211;purge snoopy, if you are on Debian).
Here are some symptoms that you might [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent roughly 2 days trying to figure out why I could not start a <a href="http://www.rabbitmq.com">rabbitmq</a> broker on a Debian machine. To make a long story short, it was caused by snoopy. Snoopy fubars erlang. Solution is to remove snoopy (dpkg &#8211;purge snoopy, if you are on Debian).</p>
<p>Here are some symptoms that you might see:</p>
<ul>
<li>net_adm:names() returns {error,timeout} when you do it inside &#8220;erl -sname foo&#8221;</li>
<li>if you run epmd -d -d -d -d -d  in your terminal and launch erl -sname foo, you will get the registration (ALIVE2_REQ, ALIVE2_RESP) but there will be no more communication between epmd and foo no matter what you do, until you Ctrl+C from foo. Ideally, you should be able to see PORT2_REQ and PORT2_RESP when doing net_adm:ping.</li>
<li>&#8220;erl -sname foo&#8221; and &#8220;erl -sname bar&#8221; on the same machine will not be able to ping each other with &#8220;net_adm:ping(&#8217;foo@host&#8217;).&#8221; or communicate with each other.</li>
<li>inet:gethostbyname(&#8221;any.domain.name&#8221;) will return {error,timeout} for all domains, even for names in your /etc/hosts, when you do &#8220;erl -sname foo&#8221; but might work when you do just &#8220;erl&#8221; (not starting a distributed node).</li>
</ul>
<p>RabbitMQ related symptoms:</p>
<ul>
<li>broker will not start using /etc/init.d/rabbitmq-server start</li>
<li>rabbitmqctl status will always fail with badrpc error</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2008/04/22/snoopy-fubars-erlang/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Best April Fools&#8217; Day Joke Today</title>
		<link>http://somic.org/2008/04/01/best-april-fools-day-joke-today/</link>
		<comments>http://somic.org/2008/04/01/best-april-fools-day-joke-today/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 17:33:04 +0000</pubDate>
		<dc:creator>Dmitriy</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://somic-org.homelinux.org/blog/2008/04/01/best-april-fools-day-joke-today/</guid>
		<description><![CDATA[http://damienkatz.net/2008/04/couchdb_language_change.html
Or is it not a joke?&#8230;
]]></description>
			<content:encoded><![CDATA[<p><a href="http://damienkatz.net/2008/04/couchdb_language_change.html">http://damienkatz.net/2008/04/couchdb_language_change.html</a></p>
<p>Or is it not a joke?&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://somic.org/2008/04/01/best-april-fools-day-joke-today/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
