jeudi 16 avril 2015

Design pattern for receiving messages

I am trying to find a proper design patter which will solve the following scenarios in an elegant way:


There is a backend system which communicates with clients using messaging API (specifically it is AMQP protocol / Apache Qpidd, but it is not important now). Client application is written in .NET/C# and there are following scenarios which need to be solved:




  • client sends a request and receives 1 response.




  • client sends a request and receives many different responses.




  • client sends many requests at once and receives many responses.




The relation between request and response is based on the correlation id. When client receives a message, it knows which request it is related to.


Sometimes it doesn't matter when the response is received, client doesn't wait for it and it is processed asynchronously.


But in other cases, client needs to wait for the response(s) synchronously. The most challenging part is when there are more expected responses and client needs to wait for all of them synchronously.


One can find a lot of different approaches, but I am always looking for the most elegant solution (my mind is setup that way, I can get rid of that :-)).


I would appreciate any ideas about the design pattern suitable for this solution.


Thanks a lot


Aucun commentaire:

Enregistrer un commentaire