[BUG] EventBusRabbitMQ Message Processing Problem #888
Description
I'm examining RabbitMqEventBus functionality with some integration and functional tests for using it in a project. I found that according to RabbitMq.Client source code on the consumer, Received Event is an EventHandler<>, therefor the client library didn't handle for any asynchronous operations (Like Exception handling in async methods!).
///<summary>Event fired on HandleBasicDeliver.</summary>
public event EventHandler<BasicDeliverEventArgs> Received;
But in EventBusRabbitMq, message consuming handled with an async subscription.
It will causes two problems:
-
Processing messages non-sequentially:
As EventBusRabbitMq uses async subscription for the Received Event, It will causes to dedicate a separate Thread for every message processing (Threads count will be limited to the client QoS config). In this case for example if messages M1, M2 were in the queue, both of them will be processed simultaneously. In the cases that choreography of events were important (Like when events related to a specific entity) this will causes a disaster.
Beside everything, queued messages must really be processed sequentially. Receiving every types of messages in one queue for a microservice (That this kind of design is in question itself!) won't be the reason to process messages non-sequentially. -
Exception Handling problems:
As RabbitMq.Client doesn't handle the Received Event asynchronously, any Exception throw during processing a message won't be caught, therefor causes application or test down. The subscribtion for CallbackException Event in the EventBusRabbitMqBus, won't be invoked in this case.