<p>Hi Michael, now I realize this scenario is not one RabbitMQ is supposed to handle out of the box, thanks for clearing it out. Nonetheless I&#39;m afraid building support for it inside the broker is not something I can afford, therefore I think I will build something at a higher level externally, as you suggested with some collaboration from the client side.</p>

<div class="gmail_quote">On Jun 2, 2011 12:30 PM, &quot;Michael Bridgen&quot; &lt;<a href="mailto:mikeb@rabbitmq.com">mikeb@rabbitmq.com</a>&gt; wrote:<br type="attribution">&gt;&gt; WRT this:<br>&gt;&gt;<br>&gt;&gt; /When I was writing it, I thought it would be really easy to, when a new<br>
&gt;&gt; queue is bound to this exchange, go fetch all the messages in that<br>&gt;&gt; bucket and send them to the queue.///<br>&gt;&gt;<br>&gt;&gt; I�m not sure it is, that was my main question actually. How do you<br>&gt;&gt; figure out how to join the messages stored in the bucket and those<br>
&gt;&gt; arriving live so that the last message you send to the queue from those<br>&gt;&gt; picked up from the bucket is followed exactly by its logical successor<br>&gt;&gt; from those coming live?<br>&gt;&gt;<br>&gt;&gt; Say I have messages 1..100 being published to the exchange, each time<br>
&gt;&gt; one arrives it�s stored. The exchange has received the first 50 messages<br>&gt;&gt; and a client performs a binding of a queue to the exchange. So you start<br>&gt;&gt; pulling the messages from the storage and sending them to the queue<br>
&gt;&gt; before forwarding any live messages. While you are pulling them out of<br>&gt;&gt; the storage messages 51..60 are published to the exchange, how do you<br>&gt;&gt; deal with them? Do you always pull from the storage? When do you stop<br>
&gt;&gt; pulling from the storage and relay to the queue directly what is being<br>&gt;&gt; published to the exchange if you don�t know whether any new messages<br>&gt;&gt; have arrived while you were pulling from the storage?<br>
&gt; <br>&gt; My inclination with this and similar use cases* is that they deserve <br>&gt; their own content class (alongside &#39;exchange&#39;, &#39;queue&#39;, etc.).<br>&gt; <br>&gt; By way of illustration: the last-value-caching exchange, though it was <br>
&gt; developed as a verification of the exchange type mechanism, is rather <br>&gt; awkward; in the main because it is encoded in the existing AMQP <br>&gt; operations (bind, consume), and these aren&#39;t the right vocabulary for <br>
&gt; the intended use.  See the &quot;Limitations&quot; section of<br>&gt; <a href="https://github.com/squaremo/rabbitmq-lvc-plugin">https://github.com/squaremo/rabbitmq-lvc-plugin</a>.<br>&gt; <br>&gt; There&#39;s two natural generalisations of LVC: one is to keep an arbitrary <br>
&gt; number of values around, and the other is to make the hold higher-order <br>&gt; (i.e., instead of replaying values, replay some aggregate of values). <br>&gt; Neither of these really fit in AMQP as it stands, not in the available <br>
&gt; methods or their semantics.<br>&gt; <br>&gt; Anyway.  So that this is helpful and not just me kicking AMQP, here is a <br>&gt; suggestion: if the consumers are made to co-operate just slightly you <br>&gt; can get your proxy idea to work. Just use different queues for the <br>
&gt; replay and the live.  Subscribe the live first and note the most recent <br>&gt; message you know about at that time; then publish your saved messages <br>&gt; through to that message into the replay queue.  The consumer, when it <br>
&gt; hears back from the proxy, drains the replay queue then starts on the <br>&gt; live queue.<br>&gt; <br>&gt; <br>&gt; Michael<br>&gt; <br>&gt; *I call the category &quot;value+updates&quot;, and the synchronisation problem <br>
&gt; you describe above is the essence of it.<br>&gt; <br>&gt;&gt; _______________________________________________________________<br>&gt;&gt;<br>&gt;&gt; *Simone Busoli*<br>&gt;&gt; Direzione risorse umane e segreteria generale � Sistemi informativi<br>
&gt;&gt; gestione sportiva<br>&gt;&gt; /Collaboratore/<br>&gt;&gt;<br>&gt;&gt; *Ferrari S.p.A. * Via Ascari 55/57, 41053, Maranello (MO); Italy<br>&gt;&gt; *T* (+39) 0536-949.850<br>&gt;&gt; *E* _<a href="mailto:simone.busoli@ferrari.com">simone.busoli@ferrari.com</a> &lt;mailto:<a href="mailto:simone.busoli@ferrari.com">simone.busoli@ferrari.com</a>&gt;_<br>
&gt;&gt; _<a href="http://www.ferrari.com">www.ferrari.com</a> &lt;<a href="http://www.ferrari.com/">http://www.ferrari.com/</a>&gt;_<br>&gt;&gt;<br>&gt;&gt; *From:* Jon Brisbin [mailto:<a href="mailto:jon@jbrisbin.com">jon@jbrisbin.com</a>]<br>
&gt;&gt; *Sent:* Wednesday, June 01, 2011 4:59 PM<br>&gt;&gt; *To:* Busoli, Simone<br>&gt;&gt; *Cc:* <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>&gt;&gt; *Subject:* Re: [rabbitmq-discuss] How to handle full exchange history<br>
&gt;&gt; delivery<br>&gt;&gt;<br>&gt;&gt; Maybe I wasn&#39;t being clear:<br>&gt;&gt;<br>&gt;&gt; I&#39;ve already written a custom exchange that stores every message it<br>&gt;&gt; receives in Riak (<a href="http://wiki.basho.com/">http://wiki.basho.com/</a>). I&#39;m going to be talking about<br>
&gt;&gt; it next week at Erlang Factory in London, as a matter of fact. :)<br>&gt;&gt;<br>&gt;&gt; <a href="https://github.com/jbrisbin/riak-exchange">https://github.com/jbrisbin/riak-exchange</a><br>&gt;&gt;<br>&gt;&gt; When I was writing it, I thought it would be really easy to, when a new<br>
&gt;&gt; queue is bound to this exchange, go fetch all the messages in that<br>&gt;&gt; bucket and send them to the queue.<br>&gt;&gt;<br>&gt;&gt; Since I&#39;m using Riak, the messages themselves are not all stored in memory.<br>
&gt;&gt;<br>&gt;&gt; Thanks!<br>&gt;&gt;<br>&gt;&gt; Jon Brisbin<br>&gt;&gt; http//<a href="http://jbrisbin.com">jbrisbin.com</a><br>&gt;&gt;<br>&gt;&gt; ------------------------------------------------------------------------<br>
&gt;&gt;<br>&gt;&gt;     *From: *&quot;Simone Busoli&quot; &lt;<a href="mailto:Simone.Busoli@ferrari.com">Simone.Busoli@ferrari.com</a>&gt;<br>&gt;&gt;     *To: *<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
&gt;&gt;     *Sent: *Wednesday, June 1, 2011 8:43:58 AM<br>&gt;&gt;     *Subject: *Re: [rabbitmq-discuss] How to handle full exchange<br>&gt;&gt;     history delivery<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;     That�s what I thought as well, although I�m thinking about a couple<br>
&gt;&gt;     of issues about it:<br>&gt;&gt;<br>&gt;&gt;     � Lack of knowledge about Erlang, which is the language I�d have to<br>&gt;&gt;     use to build a custom exchange, I guess<br>&gt;&gt;<br>&gt;&gt;     � Amount of memory it would require to store the entire history in<br>
&gt;&gt;     memory. It needn�t be in memory actually, but I�m not sure what<br>&gt;&gt;     would be the recommended way if the storage has to be carried out by<br>&gt;&gt;     exchange itself. Mnesia perhaps, would it make sense?<br>
&gt;&gt;<br>&gt;&gt;     _______________________________________________________________<br>&gt;&gt;<br>&gt;&gt;     *Simone Busoli*<br>&gt;&gt;     Direzione risorse umane e segreteria generale � Sistemi informativi<br>&gt;&gt;     gestione sportiva<br>
&gt;&gt;     /Collaboratore/<br>&gt;&gt;<br>&gt;&gt;     *Ferrari S.p.A. * Via Ascari 55/57, 41053, Maranello (MO); Italy<br>&gt;&gt;     *T* (+39) 0536-949.850<br>&gt;&gt;     *E* _<a href="mailto:simone.busoli@ferrari.com">simone.busoli@ferrari.com</a> &lt;mailto:<a href="mailto:simone.busoli@ferrari.com">simone.busoli@ferrari.com</a>&gt;_<br>
&gt;&gt;     _<a href="http://www.ferrari.com">www.ferrari.com</a> &lt;<a href="http://www.ferrari.com/">http://www.ferrari.com/</a>&gt;_<br>&gt;&gt;<br>&gt;&gt;     *From:* Jon Brisbin [mailto:<a href="mailto:jon@jbrisbin.com">jon@jbrisbin.com</a>]<br>
&gt;&gt;     *Sent:* Wednesday, June 01, 2011 3:38 PM<br>&gt;&gt;     *To:* Busoli, Simone<br>&gt;&gt;     *Cc:* <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>&gt;&gt;     *Subject:* Re: [rabbitmq-discuss] How to handle full exchange<br>
&gt;&gt;     history delivery<br>&gt;&gt;<br>&gt;&gt;     I&#39;ve been seriously considering adding this functionality to the<br>&gt;&gt;     Riak-backed custom exchange. It was something I thought I would add<br>&gt;&gt;     first time through but didn&#39;t.<br>
&gt;&gt;<br>&gt;&gt;     You&#39;d have to use a custom exchange. Not sure if that&#39;s an issue in<br>&gt;&gt;     your scenario or not.<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;     Thanks!<br>&gt;&gt;<br>&gt;&gt;     Jon Brisbin<br>
&gt;&gt;     http//<a href="http://jbrisbin.com">jbrisbin.com</a><br>&gt;&gt;<br>&gt;&gt;     ------------------------------------------------------------------------<br>&gt;&gt;<br>&gt;&gt;         *From: *&quot;Simone Busoli&quot; &lt;<a href="mailto:Simone.Busoli@ferrari.com">Simone.Busoli@ferrari.com</a>&gt;<br>
&gt;&gt;         *To: *<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>&gt;&gt;         *Sent: *Wednesday, June 1, 2011 5:52:24 AM<br>&gt;&gt;         *Subject: *[rabbitmq-discuss] How to handle full exchange<br>
&gt;&gt;         history delivery<br>&gt;&gt;<br>&gt;&gt;         Hi,<br>&gt;&gt;<br>&gt;&gt;         I am trying to achieve a scenario in which messages are<br>&gt;&gt;         published from some data source into a RabbitMQ exchange and<br>
&gt;&gt;         clients should be able to receive the full history of messages<br>&gt;&gt;         flown through that exchange, regardless of the exact moment in<br>&gt;&gt;         time when they connect.<br>&gt;&gt;<br>
&gt;&gt;         I�ve been thinking to solve it by setting up a proxy which<br>&gt;&gt;         subscribes to the exchange where messages are published using<br>&gt;&gt;         its own queue, keeps an internal storage of the messages and<br>
&gt;&gt;         accepts requests from clients.<br>&gt;&gt;<br>&gt;&gt;         When a request from a client arrives it just replays the full<br>&gt;&gt;         message history to the client by publishing the messages to the<br>
&gt;&gt;         client queue (supplied in the ReplyTo field), *then* binds the<br>&gt;&gt;         client queue to the messages exchange, so that the client from<br>&gt;&gt;         this moment onwards starts receiving the �live� messages, and is<br>
&gt;&gt;         pretty much unaware of what�s happened; it simply just receives<br>&gt;&gt;         the whole history.<br>&gt;&gt;<br>&gt;&gt;         Now I am under the impression that there�s a fundamental flaw in<br>&gt;&gt;         this reasoning, since the proxy cannot know when the message<br>
&gt;&gt;         history has completed and he can switch the client to the live<br>&gt;&gt;         stream, because while it is replaying historical messages to the<br>&gt;&gt;         client other live messages might be arriving on the proxy�s<br>
&gt;&gt;         queue, thus getting into an endless loop.<br>&gt;&gt;<br>&gt;&gt;         I�m probably missing something obvious, any advice about how<br>&gt;&gt;         others would approach this scenario is appreciated.<br>
&gt;&gt;<br>&gt;&gt;         Simone<br>&gt;&gt;<br>&gt;&gt;         _________________________________________________________________________________________________________________<br>&gt;&gt;         Questo messaggio e da intendersi esclusivamente ad uso del<br>
&gt;&gt;         destinatario e puo contenere informazioni che sono di natura<br>&gt;&gt;         privilegiata, confidenziale<br>&gt;&gt;         o non divulgabile secondo le leggi vigenti. Se il lettore del<br>&gt;&gt;         presente messaggio non e il destinatario designato, o il<br>
&gt;&gt;         dipendente/agente responsabile<br>&gt;&gt;         per la consegna del messaggio al destinatario designato, si<br>&gt;&gt;         informa che ogni disseminazione, distribuzione o copiatura di<br>&gt;&gt;         questa comunicazione e<br>
&gt;&gt;         strettamente proibita anche ai sensi del decreto legislativo<br>&gt;&gt;         196/03 . Se avete ricevuto questo messaggio per errore, vi<br>&gt;&gt;         preghiamo di notificarcelo<br>&gt;&gt;         immediatamente a mezzo e-mail di risposta e successivamente di<br>
&gt;&gt;         procedere alla cancellazione di questa e-mail e relativi<br>&gt;&gt;         allegati dal vostro sistema.<br>&gt;&gt;         _________________________________________________________________________________________________________________<br>
&gt;&gt;         This message is intended only for the use of the addressee and<br>&gt;&gt;         may contain information that is privileged, confidential and<br>&gt;&gt;         exempt from<br>&gt;&gt;         disclosure under applicable law. If the reader of this message<br>
&gt;&gt;         is not the intended recipient, or the employee or agent<br>&gt;&gt;         responsible for delivering the<br>&gt;&gt;         message to the intended recipient, you are hereby notified that<br>&gt;&gt;         any dissemination, distribution or copying of this communication<br>
&gt;&gt;         is strictly<br>&gt;&gt;         prohibited. If you have received this e-mail in error, please<br>&gt;&gt;         notify us immediately by return e-mail and delete this e-mail<br>&gt;&gt;         and all attachments from<br>
&gt;&gt;         your system.<br>&gt;&gt;         _________________________________________________________________________________________________________________<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;         _______________________________________________<br>
&gt;&gt;         rabbitmq-discuss mailing list<br>&gt;&gt;         <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>&gt;&gt;         &lt;mailto:<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a>&gt;<br>
&gt;&gt;         <a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>&gt;&gt;<br>&gt;&gt;     _________________________________________________________________________________________________________________<br>
&gt;&gt;     Questo messaggio � da intendersi esclusivamente ad uso del<br>&gt;&gt;     destinatario e pu� contenere informazioni che sono di natura<br>&gt;&gt;     privilegiata, confidenziale<br>&gt;&gt;     o non divulgabile secondo le leggi vigenti. Se il lettore del<br>
&gt;&gt;     presente messaggio non � il destinatario designato, o il<br>&gt;&gt;     dipendente/agente responsabile<br>&gt;&gt;     per la consegna del messaggio al destinatario designato, si informa<br>&gt;&gt;     che ogni disseminazione, distribuzione o copiatura di questa<br>
&gt;&gt;     comunicazione �<br>&gt;&gt;     strettamente proibita anche ai sensi del decreto legislativo 196/03<br>&gt;&gt;     . Se avete ricevuto questo messaggio per errore, vi preghiamo di<br>&gt;&gt;     notificarcelo<br>
&gt;&gt;     immediatamente a mezzo e-mail di risposta e successivamente di<br>&gt;&gt;     procedere alla cancellazione di questa e-mail e relativi allegati<br>&gt;&gt;     dal vostro sistema.<br>&gt;&gt;     _________________________________________________________________________________________________________________<br>
&gt;&gt;     This message is intended only for the use of the addressee and may<br>&gt;&gt;     contain information that is privileged, confidential and exempt from<br>&gt;&gt;     disclosure under applicable law. If the reader of this message is<br>
&gt;&gt;     not the intended recipient, or the employee or agent responsible for<br>&gt;&gt;     delivering the<br>&gt;&gt;     message to the intended recipient, you are hereby notified that any<br>&gt;&gt;     dissemination, distribution or copying of this communication is<br>
&gt;&gt;     strictly<br>&gt;&gt;     prohibited. If you have received this e-mail in error, please notify<br>&gt;&gt;     us immediately by return e-mail and delete this e-mail and all<br>&gt;&gt;     attachments from<br>
&gt;&gt;     your system.<br>&gt;&gt;     _________________________________________________________________________________________________________________<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;     _______________________________________________<br>
&gt;&gt;     rabbitmq-discuss mailing list<br>&gt;&gt;     <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>&gt;&gt;     &lt;mailto:<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a>&gt;<br>
&gt;&gt;     <a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>&gt;&gt;<br>&gt;&gt; _________________________________________________________________________________________________________________<br>
&gt;&gt; Questo messaggio � da intendersi esclusivamente ad uso del destinatario<br>&gt;&gt; e pu� contenere informazioni che sono di natura privilegiata, confidenziale<br>&gt;&gt; o non divulgabile secondo le leggi vigenti. Se il lettore del presente<br>
&gt;&gt; messaggio non � il destinatario designato, o il dipendente/agente<br>&gt;&gt; responsabile<br>&gt;&gt; per la consegna del messaggio al destinatario designato, si informa che<br>&gt;&gt; ogni disseminazione, distribuzione o copiatura di questa comunicazione �<br>
&gt;&gt; strettamente proibita anche ai sensi del decreto legislativo 196/03 . Se<br>&gt;&gt; avete ricevuto questo messaggio per errore, vi preghiamo di notificarcelo<br>&gt;&gt; immediatamente a mezzo e-mail di risposta e successivamente di procedere<br>
&gt;&gt; alla cancellazione di questa e-mail e relativi allegati dal vostro sistema.<br>&gt;&gt; _________________________________________________________________________________________________________________<br>&gt;&gt; This message is intended only for the use of the addressee and may<br>
&gt;&gt; contain information that is privileged, confidential and exempt from<br>&gt;&gt; disclosure under applicable law. If the reader of this message is not<br>&gt;&gt; the intended recipient, or the employee or agent responsible for<br>
&gt;&gt; delivering the<br>&gt;&gt; message to the intended recipient, you are hereby notified that any<br>&gt;&gt; dissemination, distribution or copying of this communication is strictly<br>&gt;&gt; prohibited. If you have received this e-mail in error, please notify us<br>
&gt;&gt; immediately by return e-mail and delete this e-mail and all attachments<br>&gt;&gt; from<br>&gt;&gt; your system.<br>&gt;&gt; _________________________________________________________________________________________________________________<br>
&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; _______________________________________________<br>&gt;&gt; rabbitmq-discuss mailing list<br>&gt;&gt; <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
&gt;&gt; <a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>&gt; <br>&gt; _______________________________________________<br>
&gt; rabbitmq-discuss mailing list<br>&gt; <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>&gt; <a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div>