Quantcast
Channel: Active questions tagged consumer - Stack Overflow
Viewing all articles
Browse latest Browse all 90

Acknowledge when the client has completely processed the message. Rabbitmq

$
0
0
var consumer = new EventingBasicConsumer(channel);consumer.Received +=  (model, ea) =>{    var eventName = ea.RoutingKey;    var message = Encoding.UTF8.GetString(ea.Body);    ProcessEvent(eventName, message);    channel.BasicAck(ea.DeliveryTag, multiple: false);};channel.BasicConsume(queue: _queueName,    autoAck: false,    consumer: consumer);
 private void ProcessEvent(string eventName, string message)` { //code send the acknowledgement here, before completing the processing   if (_subsManager.HasSubscriptionsForEvent(eventName)`   {    using (var scope = _autofac.BeginLifetimeScope(AUTOFAC_SCOPE_NAME))`     {      var subscriptions = _subsManager.GetHandlersForEvent(eventName);`        foreach (var subscription in subscriptions)`          {             if (subscription.IsDynamic)`        {           var handler = scope.ResolveOptional(subscription.HandlerType) as IDynamicIntegrationEventHandler;          dynamic eventData = JObject.Parse(message);`            handler.Handle(eventData);                                 }

I need to acknowledge when the client has completely processed the message using RabbitMQ. In my application, acknowledgement comes once consumer constructor is called. I want it to be done only after processing is finished. I have created a common class for message Broker. but I want this functionality for a particular subscribe event. Here is my code, I am processing the event**


Viewing all articles
Browse latest Browse all 90

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>