Welcome to MSDN Blogs Sign in | Join | Help

Welcome to The Metaverse

Navigating the service-oriented, identity aware metaverse

News

  • Disclaimer:
    The content of this blog are my own personal opinions and do not necessarily represent Microsoft's position, commitments or strategy. In addition, my thoughts and opinions often change, and as a weblog is intended to provide a semi-permanent point in time snapshot you should not consider out of date posts to reflect my current thoughts and opinions.




    Add to Technorati Favorites
"RPC" vs. Messaging in WCF

I have been in many conversations recently, both online and in the real world, involving the debate around whether or not a distributed systems technology such as Indigo should offer what some people call an "RPC" programming model and/or a message-passing programming model.

Let me just clarify that the use of the term "RPC" in this context is, I think, misleading because most people understand RPC to refers to a particular technology implemnetation of the concept of RPC in some flavour of  DCE RPC. What we're really talking about here is, in fact, the way in which we express how a caller requests a (potentially) remote service to perform an action and return results.

One camp says that if you're talking to a service, you should always explicitly form a message and use explicit message-passing infrastructure to send the message to the service and, optionally, to recieve the response. The following is an example of a potential implementation of such a mechanism (from the caller's perspective):

Channel chan = new ChannelFactory.CreateChannel(endpointAddress);
ActionInvocationMessage msg = new ActionInvocationMessage();
msg.Action = "SayHello";
msg.Parameters.Add(new StringParameter("Forename", "Rich"));
msg.Parameters.Add(new StringParameter("Surname", "Turner"));
Console.WriteLine(chan.SendMessageSync(msg, new SayHelloCallback(HandleResponse)));

The other camp aims to simplify the developer experience by reusing development constructs in wide use today that result in code such as the following:

HelloWorldProxy proxy = new HelloWorldProxy(endpointAddress);
Console.WriteLine(proxy.SayHello("Rich", "Turner"));

We deliberated over this issue for MONTHS when creating WCF. We went around and around arguing each position, mocking up code examples, we worked with focus groups both inside and eternally to Microsoft. We wrote demo apps and we gathered all the feedback.

And the result? There wasn't one! The two camps were deeply divided on this issue. So what did we do? We built both into the very core of WCF!

There are those who demand to explicitly craft and manage every single message interaction between caller and sevice and there are a variety of reasons for this. There are also those who do not need to do so and would rather leave it up to the infrastructure to marshal calls across whatever wire connects the caller and the required sevice(s). There are those who wish to asyncronously send messages and handle the response to those messages. There are those who want to ayncronously invoke actions on a service and asyncronously handle the responses to those invocations. There are those who want to send and receive messages in any order at any time via a duplex communications mechanism. There are those who wish to invoke methods on services and to asyncronously handle responses in any order. WCF supports all of these notions. There are many other needs that WCF also supports including securing messages, increasing the reliability of sending messages or invoking methods, providing rich session support, enabling two-phase-commit distributed transactions., etc.

Because WCF lets you achieve most goals by explicitly writing messaging code or by using the infrastructure to marshal your invocations, you get to choose which programming style best meets your needs, your schedules and the capabilities of your developers.

Now, there will be some from one camp or another who will be itching to hit the "Post a Reply" button to tell me that we shouldn't support both methods and that one or the other should be removed. However, both camps need to understand that WCF is a general-purpose foundation for building app-app, service-service communications and needs to provide as broad, deep and rich set of capabilities as we possibly can in order to meet the requirements of a hugely diverse community.

By providing as much flexibility in WCF as we have is a testament to the fact that we fully understand the perspectives of both camps and wish to provide as much value to each as possible. The WCF team understand a great deal about this space having built and delivered everything from RPC, DCOM, ES & COM+, System.Messaging & MSMQ, ASMX, WSE, Remoting, etc. We've learned a lot about what works and what doesn't - from many viewpoints - productivity, performance, reliability, architecture, scalability, availability, etc. We've made subtle changes to the way in which proxies are generated (by suffixing "Proxy" to the name of service proxy classes) so that we help increase the awareness of service consumers that they're not invoking methods on local objects, whilst not impeding developer productivity.

If you think we've got something wrong, then please send your working code samples to us via the Indigo newsgroup along with what you'd like the code to look like. We can't guarantee to make the changes requested, but we are keen to make sure that we're meetings your expectations.

Posted: Thursday, September 08, 2005 8:42 AM by RichTurner666

Comments

Sam Gentile said:

Nice post to mine (and other's) questions. I am still processing to make sure I understand.
# September 8, 2005 3:36 PM

Javier G. Lozano said:

# September 8, 2005 11:37 PM

Tom Fuller said:

Although I will not be at PDC I am starting to picture an extremely passionate, sweatty, loud Rich Turner on the stage yelling "AGILITY" "AGILITY" "AGILITY" "AGILITY" .... you get the idea. Hmmmmm, where have I seen something like that before :)

Thanks again for the level set Rich, WCF gives us both and we as application desingers/developers are responsible for showcasing it depending on the specific scenario. I think the argument from the message-oriented guys/gals invariably seems to come back to tool support for the message-oriented approach. But, what else could be there? Better XSD creation support ... VS 2005 has it. More control over WSDL generation ... isn't that the point of splitting the work out into three distinct contract types? More XML api stuff when dealing with the message object .... not sure what to say here I guess you could build intellisense on top of the message object based on a predefined XSD for a message, I haven't used the message type enough in my WCF service samples to know ... does this exist?

The Message oriented guys/gals always argue that "Biztalk gets it right" because of its ultimate reliance on XML as its native transport. Doesn't WCF really use XML as its transport when you get right down to it. All of this argument is about how we get it to XML and how we get it back from XML. I have to admit to only just now starting to get ramped up on Biztalk 2004 and I'm anxiously awaiting readable materials on 2006. What else in the tools for Biztalk reinforces message-orientation?

At the end of the day, this point you make above on RPC vs. MO is one of good design strategies on a case by case basis. If I want to be building loosley coupled service-oriented parts then I probably want to avoid heavy "RPC" stylings (sorry I know you hate that usage but it just works in my mind for things like 'out' parms or heavy typed services). On the other hand, if I'm simply distributing my business logic for a fat client then being tightly coupled is not an issue, why wouldn't I go ahead and use the RPC style features.

Works for me Rich, I think i "get it".
# September 9, 2005 4:56 AM

RichTurner666 said:

Hey Tom. Thanks for your thoughts :)

I was replying to this thread, but then some of it turned into a post! http://blogs.msdn.com/richardt/archive/2005/09/09/463020.aspx

To be honest though, I think there's too much attention paid to pointy brackets.

Sure, today BizTalk deals internally with XML and transforms incoming messages and outgoing messages as appropriate.

WCF represents messages internally in a message structure that closely resembles a SOAP message (collection of headers + body + properties) but it's only when messages hit the bottom-most end of the Indigo bindings are they actually searialized into text-XML or binary-XML or some-custom-encoding-of-your-own-choosing! XML is a useful protocol that helps is construct rich data into a (generally) consistent (fairly) easily parseable form.

That's it. XML is not gonna solve world-hunger, and it's not gonna eradicate hate and fear. To be hoenst, I expect (although I know many others disagree) that in 10 years time, we'll be far less concerned with pointy-brackets and that they'll be consdiered similar to how we consider TCP or UDP today - largely as a transport-level consideration.

Of course, XML will still have a place to play in representing data, but as tools improve, you'll care less. Today, do you even notice that the word docs you write, the emails you send and the web pages you view are generally represented/serialized as XML? I certainly don't!
# September 9, 2005 2:22 PM

Arnon Rotem-Gal-Oz said:

I would actually expect the messaging code to be more along these lines:
Channel chan = new ChannelFactory.CreateChannel(endpointAddress);
ActionInvocationMessage msg = new ActionInvocationMessage<HelloMsg>
msg.Forename="Rich";
msg.Surname="Turner";
Console.WriteLine(chan.SendMessageAsync(msg));

In any event, the problem with the proxy semantics is that it encourages distributed object approach and even more importantly hides the fact that the the end point is remote - you may want to look at the following paper (published in 1994..)
http://research.sun.com/techrep/1994/smli_tr-94-29.pdf

# September 11, 2005 4:15 PM

MSMQ from the plumber's mate said:

Everything starts here at the MSDN Library - documentation, concepts, tutorials, primers, guideliness,

# February 6, 2008 6:24 AM
Anonymous comments are disabled
Page view tracker