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**