<div dir="ltr"><p style="font-size: 13.600000381469727px; clear: both; word-wrap: break-word; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.600000381469727px;">I configured producer to a fanout exchange and a queue, and same with consumer. For some reason special messages are not broadcasted, while each receiver randomly receives normal messages one at a time. Can someone help me the loophole in my approach. Am I doing something not supposed to ?</p><pre class="lang-java prettyprint prettyprinted" style="margin-bottom: 10px; padding: 5px; font-size: 13.600000381469727px; background-color: rgb(238, 238, 238); font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; overflow: auto; width: auto; max-height: 600px; color: rgb(0, 0, 0); line-height: 17.600000381469727px;"><code style="font-size: 13.600000381469727px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif;"><span class="com" style="font-size: 13.600000381469727px; background-color: transparent; color: gray;">// My producer</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">String</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> fanExName </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">"myFanEx"</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">;</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">String</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> qName </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">"myQ"</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">;</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="com" style="font-size: 13.600000381469727px; background-color: transparent; color: gray;">// setup</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">queueDeclare</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">qName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">false</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">false</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">false</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">null</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">exchangeDeclare</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">fanExName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">"fanout"</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="com" style="font-size: 13.600000381469727px; background-color: transparent; color: gray;">// usage</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">if</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">isSpecialMessage</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">msg</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">))</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">{</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">basicPublish</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">fanExName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">""</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">null</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> message</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">getBytes</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">());</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">}</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">else</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">{</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">basicPublish</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">""</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> qName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">null</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> message</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">getBytes</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">());</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">}</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">---</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="com" style="font-size: 13.600000381469727px; background-color: transparent; color: gray;">// My consumer</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">String</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> fanExName </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">"myFanEx"</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">;</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">String</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> qName </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">"myQ"</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">;</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="com" style="font-size: 13.600000381469727px; background-color: transparent; color: gray;">// setup</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">queueDeclare</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">qName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">false</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">false</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">false</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">null</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">exchangeDeclare</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">fanExName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">"fanout"</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">QueueingConsumer</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> consumer </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">new</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">QueueingConsumer</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">basicConsume</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">qName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">true</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> consumer</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
channel</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">queueBind</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">qName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> fanExName</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">,</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="str" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(128, 0, 0);">""</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">);</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="com" style="font-size: 13.600000381469727px; background-color: transparent; color: gray;">// usage</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">while</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">(</span><span class="kwd" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(0, 0, 139);">true</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">)</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">{</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">QueueingConsumer</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="typ" style="font-size: 13.600000381469727px; background-color: transparent; color: rgb(43, 145, 175);">Delivery</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> delivery </span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">=</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;"> consumer</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">.</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">nextDelivery</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">();</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">...</span><span class="pln" style="font-size: 13.600000381469727px; background-color: transparent;">
</span><span class="pun" style="font-size: 13.600000381469727px; background-color: transparent;">}</span></code></pre><p style="font-size: 13.600000381469727px; clear: both; word-wrap: break-word; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.600000381469727px;">Is there a better way of doing this. I dont want all messages to reach all recievers irrespective of type of message.</p><p style="font-size: 13.600000381469727px; clear: both; word-wrap: break-word; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.600000381469727px;"><strong style="font-size: 13.600000381469727px; background-color: transparent;">Update</strong>: I tried a different approach by using one fanout exchange + 2 queues in worker In worker, I bound a standard queue "spl-q" and a generated (random) queue to bind to the same fanout exchange. I did channel.basicConsume(queue_name, true, consumer), for both queues</p><p style="font-size: 13.600000381469727px; clear: both; word-wrap: break-word; color: rgb(0, 0, 0); font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; line-height: 17.600000381469727px;">This also did not work</p></div>