Freigeben über


Fixed Ideologies and Message exchange patterns

I had never thought that I would actually write about a topic like this but sometimes you want to organize your thoughts and have an opinion on things. Being in the performance team for WCF has got me used to a plethora of message exchange patters which we lovingly refer to as MEP. There exists a broad spectrum of coding and implementation styles which we see day in an day out. There are those that are extreme and elaborate and overwhelmingly flexible and also those that are so convoluted and rigid that its almost close to assembly.

Its good to know know what message exchange patterns would be most suited for his or her needs. I think its an overkill to adopt a strategy where your application will force itself to use only a single message exchange patter. For example an ideology like “We will do only rest style request reply throughout our system” The number of layers we need to add in order to align ourselves with a philosophy like this would probably outweigh the benefits that it provides, specifically in scenarios that aren’t suited for patterns like these.

There is a really nice article on MSDN listing out 6 message exchange patters https://msdn.microsoft.com/en-us/library/aa751829.aspx To quickly reiterate they are Datagram/Request-Reply/Duplex and 3 of these with sessions on top.  You can think of a session like a logical abstraction to say that the message is a part of a conversation. This has nothing to do with asp.net sessions and it is a way for WCF to correlate messages.

My experience it is generally more helpful to classify your problem and see what pattern really helps your issue and then slap on the contracts and protocols rather than fixing on the protocol/MEP and then forming a solution around that. I choose not to be an advocate of any particular style but I am against protocol fanatics who are inflexible and who believe that there are a fixed set of choices for certain types of scenario.

Systems are organic and so its hard to freeze implementations. The fact is patterns are similar too. Today you might be ok with TCP but there is nothing stopping you from switching to queues. As the system grows and there would be solutions you put in place to facilitate this kind of a change. Layers get added and MEPs also change.

If you have any questions on how to make a choice I would gladly try to help out.