In my Flex Java BlazeDS application I fetch the data from DataBase by the following method.
- Request Data from Flex by initiating a RemoteObject call to Java
- Execute the respective query in Java, get the result set and pass the resultset as list back to Flex
- Recieve the data in resultHandler of the Remote Object, convert it into Array Collection and display the data.
While this procedure is the text book method for BlazeDS DataSerilization, the time taken is very huge when data contains millions of records. Please find some stats below.
- Time taken to call Java from Flex : 5ms
- Time taken to establish database connection : 3000ms
- Time taken to execute query : 120ms
- Time taken to iteriate through the resultset and add data to list : 8000ms
- Time taken to pass data from Java back to Flex : 2000ms
- Time taken to convert event.result to Array Collection : 6000ms
Total Time Taken : 19125ms (for MySQL DataBase) and more for Oracle DataBase for 143,000 records in database.
Clearly the problem lies while converting ResultSet into List in Java (have to iteriate each record) and while converting List to ArrayCollection in Flex.
Is there any methods or procedures where I could speed up the process.
One possible process may be is to avoid these iteriations in Java and directly pass the ResultSet to Flex. Is that possible???