Hi Mark,<div><br></div><div>Yes a topic exchange can be ideal when you need to "listen" 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 "fanout'ed" 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"><<a href="mailto:mspetrovic@gmail.com">mspetrovic@gmail.com</a>></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'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 <<a href="mailto:mspetrovic@gmail.com">mspetrovic@gmail.com</a>> wrote:<br>
> Talking to myself here (I have no problem with that :-)), I think I<br>
> have at least one solution to this.<br>
><br>
> - Create a single exchange E<br>
> - The Publisher P creates a channel with a single queue and routing<br>
> key with the same names as the Table T in question.<br>
> - Publisher publishes a message to channel<br>
> - The Consumer C1 iterates over the table names T1 and T2 he cares<br>
> about and binds his channel to queues and routing keys with the same<br>
> name as the table name iterated over<br>
> - The Consumer C1 then starts a thread for each of these queues, and<br>
> whose run() method calls channel.basicConsume(queueName, autoAck,<br>
> rabbitConsumer)<br>
><br>
> where rabbitConsumer extends com.rabbitmq.client.DefaultConsumer.<br>
><br>
> While this seems to work, and is a bit easier to understand how to<br>
> program than header exchanges (if a header exchange would even work<br>
> for me - I wonder), I dont' like the thread-per-queue I need to spawn<br>
> to handle messages inbound for each queue.<br>
><br>
> What would be nice is if I could call channel.basicConsume(autoAck,<br>
> rabbitConsumer), which would read messages off all the queues that<br>
> were bound to that channel.<br>
><br>
> While I have something working, I'm not yet real thrilled with my<br>
> programming model.<br>
><br>
> Anybody?<br>
><br>
> Thanks!<br>
><br>
> On Tue, Jan 10, 2012 at 10:28 AM, Mark Petrovic <<a href="mailto:mspetrovic@gmail.com">mspetrovic@gmail.com</a>> wrote:<br>
>> Hello.<br>
>><br>
>> This note is longer than I thought it would be, but I do not believe<br>
>> my situation is complicated.<br>
>><br>
>> I am a RabbitMQ newcomer and am trying to identify which exchange type<br>
>> to use for my application.<br>
>><br>
>> I have a publisher P that needs to send messages about database table<br>
>> updates. A message will bear the name of a single table name,<br>
>> followed by some opaque application data:<br>
>><br>
>> Logically,<br>
>><br>
>> message == tableName | somedata<br>
>><br>
>> So consider a simplified database with three tables of interest: T1,<br>
>> T2, and T3.<br>
>><br>
>> There are two consumers, C1 and C2.<br>
>><br>
>> C1 needs to receive all messages concerning tables T1 and T2.<br>
>><br>
>> C2 needs to receive all messages concerning tables T2 and T3.<br>
>><br>
>> By implication, C1 and C2 must both receive messages about T2, where<br>
>> their interests overlap.<br>
>><br>
>> Ideally, I want to publish to a single exchange, and, therefore, my<br>
>> consumers also bind to this same single exchange. I say this because<br>
>> in fact there are a lot more than three tables to treat - there are<br>
>> almost 200. A proliferation of exchanges per-table would be not good.<br>
>><br>
>> I am considering a topic or header exchange.<br>
>><br>
>> If a header exchange, I was thinking of the publisher P putting the<br>
>> concerned table name in a "table header" and the consumers binding to<br>
>> the exchange with an interest in receiving messages with a table<br>
>> header value equal to T1, T2, or T3 (I believe x-match == any would be<br>
>> appropriate when the consumer binds). But some of my readings on<br>
>> header exhchanges here<br>
>><br>
>> <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>
>><br>
>> suggest that header exchanges may not be as useful as maybe the name<br>
>> suggests. Maybe I'm being overly paranoid.<br>
>><br>
>> And I consider topic exchanges because I know they admit messages<br>
>> about T2 consumed by C1 still being available to C2.<br>
>><br>
>> Would someone be kind enough to suggest approaches to discern which<br>
>> type of exchange to use.<br>
>><br>
>> Thank you very kindly.<br>
>><br>
>> --<br>
>> Mark<br>
><br>
><br>
><br>
> --<br>
> 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>