Alexis,<br><br>Thanks for your wonderful support and solutions.<br><br>Firstly answers to your queries:<br><br>1. Are you using fanout exchanges for this (if you want one exchange<br>
per user, then the answer should be &#39;yes&#39;).<br><br>&gt;&gt; No I am using topic exchanges because there will be three type of bindings of a queue with an excajnde. One for publishing messages to all users, another for one to one messaging and third for publishing message to a set of users.<br>
<br>2. Where is the RabbitMQ server running? �Is it on Server 1 or 2, or<br>
is it on a 3rd server? �It may not be that important but it would be<br>
good to know.<br><br>&gt;&gt; RabbitMQ Server is running on 3rd Server.<br><br><br>Back to original problem. <br><br>Actually I thought of the solution provided by you before posting the query to you. But if I follow this solution I have to perform following steps whenever a user comes online:<br>
1. Create a queue.<br>2. Create a binding of newly created queue with all exchanges of other users for retrieving messages published by other users.<br>3. Creating a binding with exchange of all users for one to one messaging.<br>
4. Create a binding with exchanges of a set of users.<br><br>When user goes offline following operation is to be performed:<br>1. Delete all the existing bindings of a queue.<br>2. Deleting the queue.<br><br>Actually I want my online and offline processes light weighted. According to me this solution would have a high impact on performance and will increase time to come online and offline. <br>
<br>Kindly let me know if this can be achieved in some other manner.<br><br>Thanks<br>Gagan Arora<br><br><br>
<br><br><br><div class="gmail_quote">On Sat, Jul 4, 2009 at 3:23 PM, Alexis Richardson <span dir="ltr">&lt;<a href="mailto:alexis.richardson@gmail.com">alexis.richardson@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Gagan,<br>
<br>
Hi - thank-you for sending the diagram and information which was very<br>
useful. �There are several ways to implement the &#39;twitter style&#39;<br>
pattern that you have described. �See below for one way to do it that<br>
illustrates the AMQP model. �It may not be the most efficient solution<br>
in terms of performance as I shall point out.<br>
<br>
Two quick questions:<br>
<br>
1. Are you using fanout exchanges for this (if you want one exchange<br>
per user, then the answer should be &#39;yes&#39;).<br>
<br>
2. Where is the RabbitMQ server running? �Is it on Server 1 or 2, or<br>
is it on a 3rd server? �It may not be that important but it would be<br>
good to know.<br>
<br>
OK - to your cases -<br>
<br>
Case1: User B sending his message to UserB Exchange which will route<br>
message to User A queue but User A is not connected to any of servers.<br>
At this point of �all messages sent to Queue A should be dropped.<br>
<br>
&gt;&gt;&gt; One way to do this is to identify the lifecycle of Queue A with the presence of User A on servers 1 and 2. �In other words, when User A is not connected to server 1, and also not connected to server 2, then Queue A does not exist. �Note - This is not the only way to achieve what you want but it may be the least fiddly :-)<br>

<br>
Case2: User A connected to server 1 but UserA consumer is not yet<br>
subscribed to UserA queue. If UserB sends any message to its exchange<br>
which is routed to Queue of UserA. At this moment of time I want all<br>
messages to be stored in queue.<br>
<br>
&gt;&gt;&gt; One way to do this (continuing from the above) is to create Queue A immediately after UserA connects to server 1. �This is an action that server 1 can initiate on behalf of UserA. �After Queue A has been created, then it should be bound to all exchanges from which it will receive messages, such as UserB&#39;s exchange. �This will then have the stated effect you seek &quot;If UserB sends any message to its exchange [it] is routed to Queue of UserA.&quot;. �Also, because UserA&#39;s consumer has not yet started consuming messages from Queue A, the messages will all remain stored in the queue.<br>

<br>
&gt;&gt;&gt; In addition, if instead of proceeding to Case 3, we revert to Case 1, for example User A disconnects from Server 1, then Queue A can simply be deleted (along with its contents). �(See also Case 5 below)<br>
<br>
&gt;&gt;&gt; However - while simple, the above is possibly not the most performant solution if (a) you are running RabbitMQ in clustered mode and (b) your Users generally follow a lot of other Users and (c) they connect and disconnect frequently. �This is because the effect of (c) is to frequuently update the routing table, possibly with a lot of binding/routing data (b), and then replicating it across the cluster (a).<br>

<br>
&gt;&gt;&gt; Let us know if you want more info about other ways to do this.<br>
<br>
<br>
Case3: User A is connected to both servers and UserA consumer is<br>
subscribed to UserA queue. If UserB sends any message to its exchange<br>
which is routed to Queue of UserA. At this moment of time I want all<br>
messages stored in queue to be delievered plus any other incoming<br>
message should also be routed.<br>
<br>
&gt;&gt;&gt; In any case, to achieve this, just start consuming messages from Queue A.<br>
<br>
&gt;&gt;&gt; I assume by &#39;delivered&#39;, you mean &#39;delivered to UserA&#39;s consumer&#39;. �Where is that running?<br>
<br>
<br>
<br>
<br>
Case4: User A is connected to both servers and UserA consumer is<br>
subscribed to UserA queue. Now User disconnects from Server 2. If<br>
UserB sends any message to its exchange which is routed to Queue of<br>
UserA. Again I want to store all messages.<br>
<br>
&gt;&gt;&gt; To achieve this, just stop consuming messages from Queue A. �They will be stored in Queue A.<br>
<br>
<br>
<br>
Case5: If user A is disconnected from both servers. Initial state is<br>
achieved again.<br>
<br>
&gt;&gt;&gt; When User A disconnects from Server 1, then Server 1 can tell RabbitMQ to delete Queue A (along with its contents)<br>
<br>
Cheers,<br>
<font color="#888888"><br>
alexis<br>
</font><div><div></div><div class="h5"><br>
<br>
<br>
<br>
<br>
<br>
On Fri, Jul 3, 2009 at 5:05 PM, GAGAN ARORA&lt;<a href="mailto:gaganarora.itm@gmail.com">gaganarora.itm@gmail.com</a>&gt; wrote:<br>
&gt; Hi Alexis<br>
&gt; Attaching a doc having architecture diagram and cases desired. Hope this<br>
&gt; would make things more clear to you.<br>
&gt; Thanks<br>
&gt; Gagan Arora<br>
&gt;<br>
&gt; On Fri, Jul 3, 2009 at 8:23 PM, Alexis Richardson<br>
&gt; &lt;<a href="mailto:alexis.richardson@gmail.com">alexis.richardson@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Gagan,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m a bit confused about what you are trying to do. �I think what you<br>
&gt;&gt; describe is possible but I am not sure what role is being played by<br>
&gt;&gt; your two servers. �Is RabbitMQ running on both of them, one of them,<br>
&gt;&gt; or neither? �You may find it easier to just use one RabbitMQ server.<br>
&gt;&gt;<br>
&gt;&gt; Can you send a drawing of what your desired configuration is?<br>
&gt;&gt;<br>
&gt;&gt; alexis<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Fri, Jul 3, 2009 at 3:08 PM, GAGAN ARORA&lt;<a href="mailto:gaganarora.itm@gmail.com">gaganarora.itm@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt; Hi<br>
&gt;&gt; &gt; I am developing a system in which a user will connect to two servers. On<br>
&gt;&gt; &gt; connecting to first server he will become online and will send his<br>
&gt;&gt; &gt; presence<br>
&gt;&gt; &gt; update but he will receive presence updates only once he is connected to<br>
&gt;&gt; &gt; other server as his consumer subscribes to his queue after connecting to<br>
&gt;&gt; &gt; second server.<br>
&gt;&gt; &gt; I am using one exchange and one queue per user. So if one user comes<br>
&gt;&gt; &gt; online<br>
&gt;&gt; &gt; then he will send his presence update to his exchange and users bound to<br>
&gt;&gt; &gt; that will receive updates.<br>
&gt;&gt; &gt; I need to configure a queue which would hold messages for user who has<br>
&gt;&gt; &gt; just<br>
&gt;&gt; &gt; came online until he is connected to other server. After connecting to<br>
&gt;&gt; &gt; second server all messages will be consumed. All messages sent to queue<br>
&gt;&gt; &gt; will<br>
&gt;&gt; &gt; be dropped once user goes offline.<br>
&gt;&gt; &gt; Is it possible?<br>
&gt;&gt; &gt; Thanks<br>
&gt;&gt; &gt; Gagan Arora<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; rabbitmq-discuss mailing list<br>
&gt;&gt; &gt; <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
&gt;&gt; &gt; <a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>