public void StartConsumer(string exchangeName, string queueName, AsyncEventHandler<BasicDeliverEventArgs> onMessageReceived){ var connection = _connection.GetConnection(); _channel = connection.CreateModel();
_channel.ExchangeDeclare(exchangeName, ExchangeType.Topic, true); _channel.QueueDeclare(queueName, true, false, _connection.AutoDeleteQueues, null); _channel.QueueBind(queueName, exchangeName, "#", null);
// AsyncEventingBasicConsumer causes timeout when trying to create another Channel on the same Connection... // also if Chanel is reused then QueueDeclare is failing with the timeout. // this does not happen with EventingBasicConsumer var consumer = new AsyncEventingBasicConsumer(_channel); consumer.Received += (sender, args) => OnMessageReceived(connection, _channel, args); _channel.BasicConsume(queueName, false, consumer);}
public async Task OnMessageReceived(IConnection connection, IModel channel, BasicDeliverEventArgs received){ try { Console.WriteLine("Message received!"); // exception happens here! var otherChannel = connection.CreateModel(); otherChannel.QueueDeclare("test", true, false, false, null); channel.BasicAck(received.DeliveryTag, false); Console.WriteLine("Message consumed!"); } catch (Exception e) { Console.WriteLine(e); channel.BasicNack(received.DeliveryTag, false, true); throw; }}
System.TimeoutException: The operation has timed out. at RabbitMQ.Util.BlockingCell.GetValue(TimeSpan timeout) at RabbitMQ.Client.Impl.SimpleBlockingRpcContinuation.GetReply(TimeSpan timeout) at RabbitMQ.Client.Impl.ModelBase.ModelRpc(MethodBase method, ContentHeaderBase header, Byte[] body) at RabbitMQ.Client.Framing.Impl.Model._Private_ChannelOpen(String outOfBand) at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.CreateNonRecoveringModel() at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.CreateModel() at Messaging.Registration`1.OnMessageReceived(IConnection connection, BasicDeliverEventArgs received)
in d:\dev\messaging\sources\Research\Registration.cs:line 71
channel.QueueDeclare("test", true, false, false, null);
System.TimeoutException: The operation has timed out. at RabbitMQ.Util.BlockingCell.GetValue(TimeSpan timeout) at RabbitMQ.Client.Impl.SimpleBlockingRpcContinuation.GetReply(TimeSpan timeout) at RabbitMQ.Client.Impl.ModelBase.QueueDeclare(String queue, Boolean passive, Boolean durable, Boolean exclusive, Boolean autoDelete, IDictionary`2 arguments) at RabbitMQ.Client.Impl.AutorecoveringModel.QueueDeclare(String queue, Boolean durable, Boolean exclusive, Boolean autoDelete, IDictionary`2 arguments) at Messaging.Registration`1.OnMessageReceived(IConnection connection, BasicDeliverEventArgs received)
in in d:\dev\messaging\sources\Research\Registration.cs:line 71
AsyncEventingBasicConsumer
and its internal dispatch machinery is a pretty complex beast and we cannot--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitm...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.