The Galactic Patrol

Thursday, February 10, 2005

Indigo is re-released into the wild

My team and product at Microsoft are code-named 'Indigo'. The last time we publicly revealed our work-in-progress product was at the 2003 PDC; as you might expect, there has been a lot of changes since then. Yesterday, we demonstrated our latest work at the VSLive conference, which means I can now talk about my particular area of ownership; I'm a tester of the 'queue channel' (or is it 'queued channel', I can never remember). This channel blends the power of MSMQ queued messaging with the usability and flexibility of the Indigo API.

I'll give an example; Mr. Vasters recently posted a simple 'Hello World' service that uses Indigo; I'll repeat his example below, then show how to convert it to a queued service - that is, the clients write messages into the queue, and the service reads them out:

namespace IndiHello
{
[ServiceContract]
public class Hello
{
[OperationContract]
public string SayHello(string name)
{
return "Hello " + name;
}
}
class Program
{
static void Main(string[] args)
{
ServiceHost<Hello> host = new ServiceHost<Hello>(new Uri("http://localhost/hello"));
host.AddEndpoint(typeof(Hello), new BasicProfileHttpBinding(), "ep");
host.Open();
Console.WriteLine("Press ENTER to quit");
Console.ReadLine();
host.Close();
}
}
}


Here's what it looks like as a queued service; I'll mark my changes in red:

using System;
using System.ServiceModel;

namespace IndiHello
{
[ServiceContract]
public class Hello
{
[OperationContract(IsOneWay = true)]
public void SayHello(string name)
{
Console.WriteLine("Hello " + name); // can't return anything - its one-way
}
}
class Program
{
static void Main(string[] args)
{
ServiceHost<Hello> host = new ServiceHost<Hello>();
host.AddEndpoint(typeof(Hello), new NetMsmqBinding(), "net.msmq://localhost/Private$/hello/");
host.Open();
Console.WriteLine("Press ENTER to quit");
Console.ReadLine();
host.Close();
}
}
}
}

.
Pretty straightforward. Messages can only travel in one direction on a queued channel, so we make the appropriate changes for that. We adjust the binding to reflect the fact that we want to use MSMQ as our transport, not HTTP. Lastly, we change the address to use the net.msmq scheme and contain the address of an MSMQ queue that’s on the local machine.

One point I’ve glossed over – the queue that’s backing this channel needs to be created beforehand; Indigo does not create queues “under the covers”. Typically an admin would use the MSMQ MMC snap-in to create his queues; for my testing purposes, I use System.Messaging:

using System.Messaging;

string queueName = @”localhost\Private$\hello”;
if (!MessageQueue.Exists(queueName))
{
MessageQueue queue = MessageQueue.Create(queueName, true);
queue.Close();
}

8 Comments:

  • Cool stuff. Glad you can finally post about what you've been working on all this time.

    Kevin

    By Anonymous Anonymous, at 5:28 PM, February 10, 2005  

  • I thought you would be posting at blogs.msdn.com/bwill :) So much for this being your non-techie blog :-)

    By Blogger Sriram, at 3:47 AM, February 11, 2005  

  • I never intended to support two blogs - I'm switching *all* my blogging over to this new site. I just haven't blogged anything tech here until now.

    By Blogger Bruce, at 8:28 AM, February 11, 2005  

  • Very nice, I like it.

    My commect:
    The MSMQ 3.0 doesn't support reading a message from the remote transactional queue, so the indigo service always needs to be a local service to the queue.
    Am I right, or Queued Channel will handle this case using the pushing model and additional transactional response queue locally to the indigo service?

    Thanks

    Roman Kiss, MVP

    By Anonymous Anonymous, at 9:11 AM, February 11, 2005  

  • Nice ;) the transation from one channel to another looks seemless for the most part. Question just for clarification, (bear with me if I sound stupid) so you're saying that the (implementation of the) queued channel will 'handle' the details of 'listening' for messages on the queue, 'dequeueing' or 'peeking' the messages off the queue when they arrive and sending them through the processing pipline ... which eventually (if the message is processible by the pipeline) gets to the handling method? Which brings up one other question ... with the QueuedChannel do I have a choice weather the messages gets peeked or dequeued off the queue?

    Thanks in advance ;)

    By Anonymous Cordell Lawrence, at 8:04 AM, March 17, 2005  

  • Cordell - that's exactly what I'm saying. The queue channel will convert the normal "pull" model of a queue into the "push" model of method calls that are the typical Indigo object model.

    Having said that, its also not that hard to reach just a little further down into the Indigo API and call channel.Receive() to get your pull model back.

    We did trim some of the MSMQ functionality out of our queued channel implementation, for a variety of reasons. One of those things is Peek(). Another one is random access to the queue - all you ever get with the current queued channel implementation is the top message on the queue.

    We're *extremely* interested in hearing if you folks think we made the right choices in the MSMQ features we expose, and those we left out. Download the CTP bits, build some apps, and let us know!

    By Blogger Bruce, at 10:10 PM, March 17, 2005  

  • Bruce thanks for the answer. I eargly fired a Windows Server 2003 VM and installed the Whidbey CTP and installed indigo, started hacking away at a self-hosted service with "MsmqIntegrationBinding", ran the application but to my disappointment out poped an InvalidOperationException : MSMQ 3.5 or higher required. There are some posts about this on the Indigo news group. So I guess I have to wait alittle longer. :)

    By Anonymous Cordell Lawrence, at 6:20 PM, March 23, 2005  

  • Thanks for the kind words, Cordell. I didn't realize at first that the MSMQ 3.5 CTP bits weren't released yet - sorry for hyping something that isn't available yet! Rest assured, we do plan to get those bits out in the near future.

    By Blogger Bruce, at 12:45 AM, March 24, 2005  

Post a Comment

<< Home