<div dir="ltr">Hello,<br><div>I am new in Rabbit and I need to write consumer code which can 1) subscribe to queue with specified name, 2) recieve messages, 3) if another queue name is specified switch to new queue and start to recieve messages from it 4) go to step 2).</div><div><br></div><div>I use official .NET client and my code looks like:</div><div><br></div><div>\\consumer:</div><div><br></div><div>private string _currentQueue;<br></div><div><br></div><div><div>public T Consume(string queue)</div><div>{</div><div>&nbsp; &nbsp; ...</div><div>&nbsp; &nbsp; if (_currentQueue != queue) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp;Subscribe(queue);</div><div>&nbsp; &nbsp; ...&nbsp;</div><div>&nbsp; &nbsp; var ea = (BasicDeliverEventArgs) _basicConsumer.Queue.Dequeue();</div><div>&nbsp; &nbsp; ... &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>}</div></div><div><br></div><div><div>private void Subscribe(string queue)</div><div>{</div><div>&nbsp; &nbsp; &nbsp; &nbsp; _currentQueue = queue;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (_basicConsumer.IsRunning)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _channel.BasicCancel(_basicConsumer.ConsumerTag); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _basicConsumer = new QueueingBasicConsumer(_channel) { ConsumerTag = GetNewTag()};</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_channel.BasicConsume(_currentQueue, false, _basicConsumer);</div><div>}</div></div><div><br></div><div>For example I have 2 queues ("A", "B") with 2 messages in each and I consume in A-B-A-B order.</div><div>My code successfully reads first messages from both A and B queues, but third time (second read from A) it stays at line</div><div>var ea = (BasicDeliverEventArgs) _basicConsumer.Queue.Dequeue();<br></div><div>and nothing happens.</div><div><br></div><div>Moreover it'is strange that via control panel I can see 2 unacked messages in both A and B queues. Corresponding to program beheaviour I can understand unacked message in A queue but not in B - second consuming from B was not started yet.</div><div><br></div><div>Please, tell me the best way to do this.</div><div><br></div><div>I consider that simple reconnection will solve my problem, but seems it's a bad practice.</div><div><br></div><div>Thanks a lot.</div></div>