November 26, 2015
Hot Topics:

Extending Microsoft's Concurrency and Coordination Runtime with MSMQ

  • August 11, 2009
  • By Jeffrey Juday
  • Send Email »
  • More Articles »


The MSMQGateway.AddQueueOut function appears below.

public Port<MessageBody> AddQueueOut(string pathToQueue)
   //This ties everything together, 
   //relates the MessageQueue to a
   //particular port, with a handler 
   //supplied by a component
   //inside of the application
   MessageQueue queue = null;
   Port<MessageBody> port = new Port<MessageBody>();
   MessageQueueMediator mediator;
   queue = MSMQHelper.GetQ(pathToQueue);
   mediator = new MessageQueueMediator(queue);
      Arbiter.Receive(true, port, mediator.SendMessage)
    return port;

The code is very similar to AddQueueIn except that it configures a port for sending a message.

MessageQueueMediator also handles sending a message. The SendMessage function appears below.

public void SendMessage(MessageBody body)
   System.Messaging.Message msg = new Message();
   MessageMapper mapper = new MessageMapper(msg);
   mapper.Body = body;
   Console.WriteLine("From Mediator Sending Message " + 
      body.MessageId + " " + 

Like a receive operation, sending leverages the MessageMapper class. MessageMapper serializes the message so its bytes can be inserted into the BodyStream of the Message class.


Originally built for Robotics, CCR is a library for coordinating tasks and handling concurrency in .NET Framework applications. CCR’s capabilities can be extended to coordinate processes across multiple machines, but doing so requires a distributed transport. Fortunately, MSMQ makes a fine transport choice.


For the source code click here

Tags: Windows, services, Microsoft, robotics, messaging

Page 3 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel