Saturday, September 18, 2010

TEAM.Commons: Messaging

This is the 6th of several posts about TEAM.Common, a set of functionality I use in every project and that I'd like to share. The index is here:

Before talking about the details of TEAM.Commons.Threading I need to explain TEAM.Commons.Messaging, a set of classes about communication between processes based on the concept of transport.


public interface ISendingTransport
    void Send(object message);
    void Send(object[] messages);


public interface IReceivingTransport
    // Blocks the current thread until a message is received.
    IList<object> WaitForMessageWithoutTimeout();

    /// Blocks the current thread until a message is received or timeout ellapses.
    IList<object> WaitForMessage(TimeSpan timeout);

There are two available implementations of these transports:


public class InProcessTransport : ISendingTransport, IReceivingTransport
This class implements both interfaces so that it can be used for communications between threads, handling all the related complexity. It's a very important piece used in the implementation of the advanced threading features in TEAM.Commons.Threading.

Send messages through an MSMQ Queue.

Receives messages from an MSMQ Queue.

Remember, you can get all this code for free at bitbucket:

Check it out to get ideas, or simply use it as it is. It's working out for me and my team.

No comments: