2 Replies Latest reply on Jan 21, 2011 7:43 AM by timfitzapi

    Dynamically invoke remote object methods?

    timfitzapi

      Please excuse my ignorance here... haven't touched Flex in 2 years, but something came up that required a change...

       

      Basically, we're moving from CF7 Standard/Flex 3 to multi-instance CF9/Flex 3 (keeping our code in compatibility mode for now).

       

      When doing a lot of remote object calls, I occasionally get a DuplicateSessionDetected error.

       

      I know this normally happens due to incorrect clustering, sessions turned off, etc. Well, our instances are properly clustered, sessions are on, and replicate sessions is checked in CF Cluster manager.

       

      So... we found that since this only happens sometimes, if we built a handler to simply "retry" the remote object method upon a fault with that error type, it would eventually get through. In tests, this works!

       

      Next step was to make this method dynamic, so we could apply it to the FAULT of each remote object method...

       

       

                        public function requestRetry(event:Fault,roName:String,methodName:String,methodParams:String):void{

       

                              var str:String =ObjectUtil.toString(event.faultCode);

       

                              error.text = str;

       

                              method.text = methodName;

       

                              remote.text ='0';

       

                              request.text = i + "," + str.search("DuplicateSessionDetected");

       

                              while(i<4 && str.search("DuplicateSessionDetected") > 0)

       

                              {

       

                                    // increment counter

       

                                    i= i + 1;

       

                                    roName[methodName(methodParams)];

       

       

                                    break;

       

                              }

       

                              //if I made it this far and throw the error

       

                              if(str.search("DuplicateSessionDetected") == 0){

       

                                    Alert.show(ObjectUtil.toString(event.faultCode));

       

                              }

       

                        }

       

       

      However, this doesn't work... how can we make this evaluate roName to the corresponding remoteObject, methodName to the corresponding method, etc...? Of course, we need it yesterday...