For my application architecture I've an API which publish messages to RabbitMQ based on requests received. A windows service acts as consumer for RabbitMQ which process messages and updates the DB or in certain cases uses SignalR callbacks.
Once a message is received with the service there are multiple files being generated, couple of DB updates and process and finally an external API is called once data is ready.
I was thinking to use Semaphore Slim library to parallel process the messages with control over thread throttling. But as I read through couple of articles I got to know that .NET TPL DataFlow or Reactive Extensions can very well handle this scenario. But I'm confused, What to choose?
All the guide and references I find online, discuss about process a list of message which is already available and to be executed. But for my case the messages are dynamic, which should be process as EventHanlder delegate of RabbitMQ .Net client is invoked.
This is the code snippet where I consume the message
var consumer = new EventingBasicConsumer(channel);
consumer.Received += (model, ea) =>
{
var body = ea.Body.ToArray();
var message = Encoding.UTF8.GetString(body);
ProcessMessage(message);
channel.BasicAck(ea.DeliveryTag, true);
};
Could you guide me to whether this scenario can be accomplished or is it over complicating my entire model?