Hi Mark,<div><br></div><div>Yes a topic exchange can be ideal when you need to &quot;listen&quot; based on several patterns. Also this exchange leaves the possibility open for new table names,�</div><div>You just have to think about the binding pattern that you want to use.</div>
<div><br></div><div>Also keep in mind that if you want message X to arrive at consumer A and B then you need one separate queue per consumer bound to that exchange using a binding key that matches the routing key used when publishing message X. What this means is that messages are &quot;fanout&#39;ed&quot; at the exchange, but once they arrive at a queue then messages are pulled out individually and once gone from the queue is not seen again.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>Alvaro<br><br><div class="gmail_quote">On Wed, Jan 11, 2012 at 1:46 AM, Mark Petrovic <span dir="ltr">&lt;<a href="mailto:mspetrovic@gmail.com">mspetrovic@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think I have a solution, better than one based on a header exchange<br>
or the scheme I outline below.<br>
<br>
It&#39;s basically this solution:<br>
<br>
<a href="http://www.rabbitmq.com/tutorials/tutorial-five-java.html" target="_blank">http://www.rabbitmq.com/tutorials/tutorial-five-java.html</a><br>
<br>
where the routing keys are the table names. �This gives me a single<br>
consumer queue bound to mulitple routing keys, which gets my job done.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Tue, Jan 10, 2012 at 2:20 PM, Mark Petrovic &lt;<a href="mailto:mspetrovic@gmail.com">mspetrovic@gmail.com</a>&gt; wrote:<br>
&gt; Talking to myself here (I have no problem with that :-)), I think I<br>
&gt; have at least one solution to this.<br>
&gt;<br>
&gt; - Create a single exchange E<br>
&gt; - The Publisher P creates a channel with a single queue and routing<br>
&gt; key with the same names as the Table T in question.<br>
&gt; - Publisher publishes a message to channel<br>
&gt; - The Consumer C1 iterates over the table names T1 and T2 he cares<br>
&gt; about and binds his channel to queues and routing keys with the same<br>
&gt; name as the table name iterated over<br>
&gt; - The Consumer C1 then starts a thread for each of these queues, and<br>
&gt; whose run() method calls channel.basicConsume(queueName, autoAck,<br>
&gt; rabbitConsumer)<br>
&gt;<br>
&gt; where rabbitConsumer extends com.rabbitmq.client.DefaultConsumer.<br>
&gt;<br>
&gt; While this seems to work, and is a bit easier to understand how to<br>
&gt; program than header exchanges (if a header exchange would even work<br>
&gt; for me - I wonder), I dont&#39; like the thread-per-queue I need to spawn<br>
&gt; to handle messages inbound for each queue.<br>
&gt;<br>
&gt; What would be nice is if I could call channel.basicConsume(autoAck,<br>
&gt; rabbitConsumer), which would read messages off all the queues that<br>
&gt; were bound to that channel.<br>
&gt;<br>
&gt; While I have something working, I&#39;m not yet real thrilled with my<br>
&gt; programming model.<br>
&gt;<br>
&gt; Anybody?<br>
&gt;<br>
&gt; Thanks!<br>
&gt;<br>
&gt; On Tue, Jan 10, 2012 at 10:28 AM, Mark Petrovic &lt;<a href="mailto:mspetrovic@gmail.com">mspetrovic@gmail.com</a>&gt; wrote:<br>
&gt;&gt; Hello.<br>
&gt;&gt;<br>
&gt;&gt; This note is longer than I thought it would be, but I do not believe<br>
&gt;&gt; my situation is complicated.<br>
&gt;&gt;<br>
&gt;&gt; I am a RabbitMQ newcomer and am trying to identify which exchange type<br>
&gt;&gt; to use for my application.<br>
&gt;&gt;<br>
&gt;&gt; I have a publisher P that needs to send messages about database table<br>
&gt;&gt; updates. �A message will bear the name of a single table name,<br>
&gt;&gt; followed by some opaque application data:<br>
&gt;&gt;<br>
&gt;&gt; Logically,<br>
&gt;&gt;<br>
&gt;&gt; message == tableName | somedata<br>
&gt;&gt;<br>
&gt;&gt; So consider a simplified database with three tables of interest: �T1,<br>
&gt;&gt; T2, and T3.<br>
&gt;&gt;<br>
&gt;&gt; There are two consumers, C1 and C2.<br>
&gt;&gt;<br>
&gt;&gt; C1 needs to receive all messages concerning tables T1 and T2.<br>
&gt;&gt;<br>
&gt;&gt; C2 needs to receive all messages concerning tables T2 and T3.<br>
&gt;&gt;<br>
&gt;&gt; By implication, C1 and C2 must both receive messages about T2, where<br>
&gt;&gt; their interests overlap.<br>
&gt;&gt;<br>
&gt;&gt; Ideally, I want to publish to a single exchange, and, therefore, my<br>
&gt;&gt; consumers also bind to this same single exchange. �I say this because<br>
&gt;&gt; in fact there are a lot more than three tables to treat - there are<br>
&gt;&gt; almost 200. �A proliferation of exchanges per-table would be not good.<br>
&gt;&gt;<br>
&gt;&gt; I am considering a topic or header exchange.<br>
&gt;&gt;<br>
&gt;&gt; If a header exchange, I was thinking of the publisher P putting the<br>
&gt;&gt; concerned table name in a &quot;table header&quot; and the consumers binding to<br>
&gt;&gt; the exchange with an interest in receiving messages with a table<br>
&gt;&gt; header value equal to T1, T2, or T3 (I believe x-match == any would be<br>
&gt;&gt; appropriate when the consumer binds). �But some of my readings on<br>
&gt;&gt; header exhchanges here<br>
&gt;&gt;<br>
&gt;&gt; <a href="http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-January/010935.html" target="_blank">http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-January/010935.html</a><br>
&gt;&gt;<br>
&gt;&gt; suggest that header exchanges may not be as useful as maybe the name<br>
&gt;&gt; suggests. �Maybe I&#39;m being overly paranoid.<br>
&gt;&gt;<br>
&gt;&gt; And I consider topic exchanges because I know they admit messages<br>
&gt;&gt; about T2 consumed by C1 still being available to C2.<br>
&gt;&gt;<br>
&gt;&gt; Would someone be kind enough to suggest approaches to discern which<br>
&gt;&gt; type of exchange to use.<br>
&gt;&gt;<br>
&gt;&gt; Thank you very kindly.<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Mark<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; Mark<br>
<br>
<br>
<br>
--<br>
Mark<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div></div></blockquote></div><br></div>