3 Replies Latest reply on Sep 16, 2009 4:35 AM by kevnug

    How to handle Remote Service retries?

    kevnug Level 1

      Hi,

       

      I'd like to retry failed remote service calls a few times before alerting the user that there really is a problem.

       

      Are there any conventions for doing this?

       

      I'm thinking of adding a retry counter somewhere - maybe the Model or ServiceLocator? - and then dispatching a new Event in the Command fault handler.

       

      public function fault(event:Object):void {

           if(retryCount < retryMax) {

                new MyServiceEvent...

           }else{

                Alert.show...

      }

       

       

      cheers

        • 1. Re: How to handle Remote Service retries?
          kevnug Level 1

          Anyone?

           

          I'm wondering whether I'll run into issues generating another event in the fault handler?  This must have been solved before! - but I've read through the Cairngorm docs, searched the forums and can't find any mention of it.  All Command Fault Handler examples I've found either do nothing or generate an Alert.

           

          I'm also having trouble simulating the timeout if anyone has any suggestions? - I'm using Zend PHP server side.

           

           

          cheers

          • 2. Re: How to handle Remote Service retries?
            chortlehoort Level 1

            What you are attempting to do is tricky with standard Cairngorm.  You will need to extend the architecture a bit to accomplish this.

             

            What my team has done is create a callback feature on the Event, so after the Command is executed, the View knows if it succeeded or failed.  The View can then be responsible (and it is the View's responsiblity, not the Command's) to attempting the Event again n number of times before failing to the user.

             

            To get a high level concept of what this means, you can read some of my articles about using Abstract Classes in Cairngorm.

             

            Abstract Events

            Abstract Commands

             

            Hope that helps

             

            - Steve

            1 person found this helpful
            • 3. Re: How to handle Remote Service retries?
              kevnug Level 1

              Thanks for the tip Steve.

               

              Not quite as easy as I hoped it was but your code certainly helps.

               

               

              cheers