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]
# 1
If you can front-end the database server with some logic, then it is simple enough to add a basic transaction Req/Ack/Timeout/resend protocol.If you include a transaction ID, then the server can determine if this is a new or a repeat request.
Paul_Carewa at 2007-7-14 19:38:22 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
try creating a record comparator that will check the database if the record already exists from the particular user.this is a long cut but since the network probs will always remain thus you have to do something about it on ur database front.(i think)
bubblesjoea at 2007-7-14 19:38:22 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
Like Paul_Carew sais:Only close the transaction if the client reports back to the server.
deepspacea at 2007-7-14 19:38:22 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4

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.

scorp546a at 2007-7-14 19:38:22 > top of Java-index,Java Mobility Forums,Java ME Technologies...