CAPTAIN SKYWARD : Just read MSDN article about “distributed Design Pattern, MSMQ, .NET” - basically bin serializing obj to MSMQ then invoker picking up and calling ICommand.ExecuteCommand. With the caveat that best suited to internal apps on a known platform. Think I will use this (expanded to cover retries etc) for a SMS backend system I’m designing. The only prob is the client needs to have same assembly installed as on the invoker. Another option for a more loose coupling would be to have XML in MSMQ Body with param name/values then the invoker reads a <procid> value and maps this to an assembly, but then the client must ensure that the XML is correct AND lose strong typing on the clients and invoker, though in this instance platform-interop not really important…
DOMINIC : Whoever thought of putting serialized command objects in a message queue should be taken out and shot, in the foot, by a copy of himself that he serialized earlier.It’s like the difference between Kirk radioing Spock on the planet surface to get some soil samples, and Kirk sending Spock a precise account of the relative location of every atom in his body so that Spock can create a copy of Kirk using a replicator and then that copy of Kirk can get the soil samples himself. Well, I think we’ve all seen that episode (or one very like it…prediction: somewhere near the end, Kirk’s shirt gets all ripped while he’s bare-knuckle ju-jitsu fighting, with himself. Evil Kirk taunts Good Kirk: “are you *sure*…you want to *live*…like common *people*???”).
CAPTAIN SKYWARD : I’ve revisited that Command/MSMQ, and basically the Command object represents a Command and some state info, the command calls into “receiver” classes that do the actual work. This makes more sense as the client only needs ref to HelloWorldCommand, then when the Invoker calls Execute. Inside Execute a HelloWorldProcesser class is instantiated and does stuff. This means that the server on which the Invoker executes needs HelloWorldCommand & HelloWorldProcesser in the GAC (or local), the client only needs HelloWorldCommand.The advantage as I see it is that (given a known set of clients and platform) as long as the correct assemblies are on the Invoker machine, the client just submits a command. Also side-by-side versioning etc. of commands can easily be achieved on the Invoker machine.
DOMINIC : So…Spock builds a copy of Kirk using the replicator, then impregnates Kirk with an alien parasite that then claws its way out of his belly and collects the soil samples. The advantage is that the Enterprise itself does not need to have any alien parasites on board…
I think that all Enterprise Architecture should be discussed in these terms, with Kirk / Picard as the agent that initiates some action, Spock / Data as the agent with the business logic, the Borg for anything distributed and so on. Beats Design Patterns any day.