Announcement Announcement Module
No announcement yet.
How to apply distributed comman pattern with spring remoting? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to apply distributed comman pattern with spring remoting?

    Hi Folks,

    I need to implement a client/server application that should use spring remoting. I already found some very helpful examples for the remoting part but I additionally want to apply the distributed command pattern. I found a design guide on how to implement it (, but Im somehow unsure how to apply it with my tiny spring remoting example.

    What I definetely want to prevent is to let the client know too much about execution logic of the concrete command. My understanding of the distributed command pattern is that the concrete execution logic is being implemented with the receiver. So I have a concrete command on the client side that just knows how to get the fitting receiver when it comes to execution on the server side. I also believe by now that I have to send the command object via spring remoting to the serverside to get executed. But here Im not quite sure if this is right.

    Here is what I have so far (more sources in the attachment):

        public static void main(String[] args) {
            CommandProvider cmdProvider = (CommandProvider) applicationContext.getBean("cmdProvider");
            AbstractCommand cmd = cmdProvider.getCommand("sayHelloCommand");
            String result = cmd.execute();
    Because the execute method in my command just contains this ...
    ... I also need to implement something like a RemoteSayHelloReceiver, that wraps the spring remoting layer on the client side. On the server side the receiver will be replaced with a receiver that contains the concrete logic (Say Hello). And here comes my problem: When I get the pattern right then the command owns the receiver. But in my scenario the receiver contains the logic for submitting the command via spring remoting which is a kind of hen & egg problem.

    public class RemoteSayHelloCommandReceiver extends CommandReceiver {
        private IBusinessService remoteService;
        protected void action() {
            if(params != null && params.containsKey("remoteCommand")) {
                AbstractCommand cmd = (AbstractCommand) params.get("remoteCommand");
            } else {
                throw new RemoteCommandNotFoundException();
    As you can see, I set the command that I want to get executed as a param and I think that this is not what the pattern was meant to be...

    Unfortunately I dont know how to solve this and where I am wrong with my approach :-(

    Any help would be appreciated!

    Thanks & Regards,