6 Replies Latest reply on May 1, 2007 2:37 PM by AndyWW

    Multiple asynchronous responses

    AndyWW
      I am attempting to use two RemoteObject requests at the same time. I want to allow the user to continue using the screen after either one of these requests has returned, and to just notify them when the second one arrives. I am trying to do this without FDS. However, though I can send both messages asynchronously the user is not able to use the interface until both calls have completed. One of the operations completes immediately, and the other one waits for 10 seconds before completing. But I do not receive a response from the first operation until the second operation has completed. The Java methods on the server are being executed in series, and therefore the method that returns immediately is waiting for completion of the method that waits 10 seconds. The AS methods on the client both return from calling the remote object operation very quickly, obviously. I am currently using a RemoteObject instances to invoke the operations on the server.
        • 1. Re: Multiple asynchronous responses
          peterent Level 2
          This is not a Flex or even a Flash problem, it is a browser constraint (or an HTTP constraint, I'm not sure which). You have given a perfect example of this. The browser has sent your request over the same open connection since both requests are going to the same destination.

          You can fake out the browser by telling it you have different endpoints. For example, if you are currently going to http://someserver.com/yourservice you can create 2 RemoteObjects with different endpoints:

          endPoint=" http://someserver.com/yourservice?dummy=1"
          endPoint=" http://someserver.com/yourservice?dummy=2"

          Now the browser will open 2 separate connections and they will run in "parallel" - the first call will return before the second call.
          • 2. Re: Multiple asynchronous responses
            AndyWW Level 1
            Thank you for your very quick reply!

            Where do I assign these values to "endPoint"? If this is in the address line of the browser then I don't think it will work, since I am only attempting to run one instance of the application (mxml). Do I need to create two RTMP streams, and to set the channel for the two destinations to use different streams?

            Let me just say briefly what I am attempting to do: I have two tasks to be executed on the server, and I want to notify the client when each of those tasks completes. I want to execute the tasks in parallel on the server, but it appears that they are executed serially -- whichever operation is requested first is executed (to completion) before the second operation begins execution. The two operations on the server are completely independent of one another.
            • 3. Re: Multiple asynchronous responses
              peterent Level 2
              The endPoint is a property of RemoteObject. You would use 2 separate RemoteObject tags in your Application. You said you were not using FDS. If you are then I don't believe this will work.
              • 4. Re: Multiple asynchronous responses
                AndyWW Level 1
                Again, a very fast response! Thank you ...

                Okay, I will check the properties of the RemoteObject class, and I can set the endPoint property. I know that this is laziness on my part (I could find out by looking at the manuals, I am sure) but could please you tell me where to get the address of the server to which the client is connected (i.e., "someserver.com" in your example)?

                Thanks again!
                • 5. Re: Multiple asynchronous responses
                  peterent Level 2
                  I put "someserver.com" because I thought you had coded a server name in the RemoteObject. Use whatever you are using now.
                  • 6. Re: Multiple asynchronous responses
                    AndyWW Level 1
                    I am so sorry, but I still do not understand how to set the endpoint. Here are the lines from my AS class:

                    public class JSINotifierList extends ArrayCollection {
                    private var remoteObject: RemoteObject;
                    public function JSINotifierList(dao: String) {
                    remoteObject = new RemoteObject();
                    remoteObject.destination = dao;
                    remoteObject.concurrency = "last";
                    remoteObject.addEventListener(ResultEvent.RESULT, handleResultEvent);
                    remoteObject.addEventListener(FaultEvent.FAULT, handleFaultEvent);
                    } // JSINotifierList()
                    public function register(... args): void {
                    var operation: AbstractOperation = remoteObject.getOperation("register");
                    operation.send(args);
                    } // register()
                    ... result and fault handling is here ...
                    }

                    Just in case it is important, here is the code from the mxml file:

                    [Bindable] private var dtoList: JSIDTOList;
                    [Bindable] private var notifierList: JSINotifierList;
                    private function appCreationComplete(): void {
                    notifierList = new JSINotifierList("JSIFlexNotifier");
                    notifierList.register([]);
                    dtoList = new JSIDTOList("JSIFlexDAO");
                    dtoList.fill(["<Pars id='all'/>", 3]);
                    } // appCreationComplete()

                    I don't know whether any of this makes sense from a Flex perspective! I am calling the "register" function from this class so that if the server wants to notify the client of something (i.e., "push" data to the client) then it will respond to the RPC call. I have other classes that provide data collections for the actual core work of the application. But I can't figure out how to get the other classes to return from RPC calls without returning from the RPC call to the JSINotifierList object. I could, of course, cancel the call to the JSINotifierList whenever I want to make a request to another destination, and then requeue the request to the JSINotifierList object when that call returns. But I was hoping to have both methods running concurrently in the web server.

                    Again, I appreciate your responses, and I am quite content for you to tell me to "go away and learn more about Flex" before attempting to do this!