J2ME end-to-end transactions
Hi Everyone
I have created a J2ME networked midlet that communicates with a server to perform database transactions.
Unfortunately occasionally, when a transaction is initiated by the J2ME client the server receives the request and processess the transaction but because of the unreliable network the client never receives the response and the user does not know if the transaction went through (a custom connection error is displayed because no response was received from the server from POV of client). This causes the user to retry the connection and thereby sometimes make a double transaction!
Can anyone suggest a solution or work around to this problem?
Thanks in advance
[709 byte] By [
scorp546a] at [2007-10-3 2:40:05]

Hi
Thanks for the replies!
A solution I thought of based on the replies is as follows:
1) client logs in and receives a session ID
2) Client generates a transaction ID locally and stores it in a local transaction manager. Client sends request + transaction ID to server.
3) Server receives request, retrieves/reserves a product in the database, and adds the transaction details (product code etc.) + transaction ID to the server's transaction manager. The transaction is not commited, but the product(e.g. virtual ticket) is sent to the client.
4) If the client does not receive the server's response, it retries N times. If the client does receive the server's response it stores the received product, but does not display it to the user, instead it attempts to acknowledge receipt to the server.
5) Server receives acknowledgement from client and commits transaction previously stored in server's transaction manager. Server responds to client with 200 OK. If the server does not receive an acknowledgement after N seconds, the transaction is abandoned and the product unreserved(i.e. made available for other clients).
6) Client receives server's response and displays product to user. (What if ack response not received?)
A successful sequence would look as follows:
client-> {request + transaction ID} -> server
client<- {product}<-server
client -> {product}->Temp product store
client->{ack product receipt}-> server
client<-{ack response}<-server
client->{product}->user display
There are still a few flaws in this approach, basically the same as the original problem but only shifted. What can I do if the server receives the acknowledgement of receipt from the client but the response does not make it back to the client? In this case the user would have been charged but would not have seen the product.
Was this ever solved in the browser environment or do all the e-commerce protocols assume a stable connection, e.g. what happens when I'm buying with my credit card and do not receive a response and try again even though server processed request? All RFCs and papers I have read thus far does not address this problem.