otm:ordering_of_messages:fifo

This is an old revision of the document!


Every day, mashup applications are more present. These applications are created with requests to several servers. Developers have to overcome the issue of creating a wrong page due to an unexpected order of executions of responses. For instance, consider a website that creates a web page from two ajax requests. If the second response is executed before the first response, the web page is created incorrectly. Instead, the if the first response is executed before the second response, the web page is created correctly. The use of the Fifo strategy can ensure, which executes the response in the same order that are sent the requests, the web page is always created correctly.

When the “activate order” button is clicked, the web page is created correctly. When the “deactivate order” button is clicked, the web page could create incorrectly. NOTE: Please first watch the application without clicking the “activate order” button to appreciate clearly the aforementioned issue.

Toggle between the code and example

The Fifo strategy is implemented as a TM advice, which is a JavaScript function, that is executed every time a response is retrieved:

var fifo = function(jp){  //jp represents the execution of a response 
    if(this.isEarly(jp)){  
        this.queue.push(jp); //if the response is retrieved early, then it is stored and not executed
    }
    else{
        jp.proceed();
        this.updateCr(jp);
        this.queue.executeEarlyJPs(); //check if now other responses can be executed
    }
};

Go back the the parent page web page.

  • otm/ordering_of_messages/fifo.1295909981.txt.gz
  • Last modified: 2011/01/24 18:59
  • by aspectscript