0

I have developed an mobile application with J2ME(LWUIT), in that I have to update an value in my mobile RMS after receiving a response from server with a completion of updation in server side, in that case when I hit call end button- red button in my mobile after hitting server and before receiving a response the mobile application get closed and the server side value is updated but mobile RMS value is not yet updated kindly let me know is any body have a idea about this.

Arun
  • 1

2 Answers2

1

The red button usually kills the application instantly and doesn't really leave you a chance to fix that. You can potentially require a callback to the server to actually commit the data there.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
0

@arun Well what you can do is.

1)Update changes at server.

2)Send the data that you wish to push to the RMS to the MIDlet along with a uniqueID. Unique id identifies every transaction uniquely.

3)At this point, the server keeps waiting for a confirmation from the MIDlet whether the MIDlet has received the data or not (lets say it waits for 20 secs)

4)Once the MIDlet receives the data, it stores it in the memory and immediately sends a confirmation to the server along with the uniqueID received (and waits for ..say.25 secs). The MIDlet also stores a count of the number of times the server has sent data with a particular unique id. So the count is initially 0 and incremented every time the server sends data with same unique id.

5)If the server receives the confirmation within 20 secs, it does nothing. After 25 secs elapse, the MIDlet will write the data to the RMS. your job is done!

5.1)If server DOES NOT receive the confirmation,it will again send the data with the same unique id (at the 21st second). The MIDlet recognizes the unique id and increments the counter which keeps track of the number of times the server has sent the same data. It again sends a confirmation and waits for 25 secs.

Now...this process can go on and on.

What you need to do is...decide when you decide to call quits on this process.

6)Ultimately,if the confirmation is not received by the server ,it rolls back the changes and sends message to the MIDlet "roll back data for unique id so and so"

7)if the midlet has not committed the data for that unique id, it ignores the messages and also the changes associated with that unique id . If already committed, it just rolls back the data for that unique id. if the request for rollback is repeated for same unique id, ignore and send a message to the server that changes have been rolled back.

8)Note: you need to send a message to the server saying that changes to RMS have been rolled back else the server will keep sending a message to rollback the changes.

Yes, this is quite complex. Check out the book. Communication Network or some thing similar by the author Behrouz Forouzan. He explains this fab.

Nikhil
  • 1,279
  • 2
  • 23
  • 43