channel.BasicQos(0, 1, false); // for fair message dispatchchannel.QueueDeclare(QueueName, true, false, false, null);
var consumer = new EventingBasicConsumer(channel);
consumer.Received += Consumer_Received;
channel.BasicConsume(QueueName, false, consumer);protected override void Consumer_Received(object sender, BasicDeliverEventArgs e){ var consumer = sender as EventingBasicConsumer; // confirmed the type by checking the methods firing the Received event
var channel = consumer?.Model;
_eventHandler.Handle(e);
MessageProcessed(channel, e);
}
protected void MessageProcessed(IModel channel, BasicDeliverEventArgs message){ SendDefaultMessageDone(message); // omitted for brevity Ack(channel, message.DeliveryTag);}
private void Ack(IModel channel, ulong deliveryTag){ Logger.Debug($"Sending Ack for message:{deliveryTag}"); if (channel == null || channel.IsClosed) { Logger.Debug($"Channel is null: {channel == null}. Channel closed: {channel?.IsClosed}. Reason: {channel?.CloseReason?.ReplyText ?? "<none>"}"); Logger.Warn($"Attempting to Ack message {deliveryTag} on channel that is <null> or closed"); return; }
channel.BasicAck(deliveryTag, false);} --
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.
// get a connectionusing (var connection = _connectionFactory.CreateConnection())using (var channel = connection.CreateModel()){ try { channel.BasicQos(0, 1, false); // for fair message dispatch channel.QueueDeclare(QueueName, true, false, false, null);
var consumer = new EventingBasicConsumer(channel);
consumer.Received += Consumer_Received;
channel.BasicConsume(QueueName, false, consumer); } catch (Exception e) { Logger.Error(e.Message, e); throw; }}To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Karl NilssonPivotal/RabbitMQ
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.