otm:ordering_of_messages:fifo

This is an old revision of the document!


A mashup application is created from the combination of information retrieved from different servers, e.g. Housing Maps. Programmers have to overcome the issue of creating an incorrect Web page due to an arbitrary (and unexpected) order of server responses. For instance, consider a Web page that is created with two Ajax requests. If the second server response is processed before the first server response, the Web page is created incorrectly. A FIFO strategy, which processes the server responses in the same order as the Ajax requests are sent, ensures that 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){
  var request = jp . target ;
  if (this.idServerRespExpected != request.idServerResp){
    this.jpsQueue.push(jp) ;
  }
  else{
    jp.proceed ( ) ;
    this.idServerRespExpected = request.idServerResp + 1;
   // executing jp proceeds that can be executed now
   this.idServerRespExpected =this.jpsQueue.execRecEarlyJPs( this . idServerRespExpected ) ;
  }
}

Go back the the parent page web page.

  • otm/ordering_of_messages/fifo.1309162907.txt.gz
  • Last modified: 2011/06/27 05:21
  • by aspectscript