Idézet (Emmanuel Lecharny <[email protected]>):

 On 7/7/10 1:49 PM, [email protected] wrote:

Hi,

we are developing a client/server application, where the server-side uses MINA as its communication framework. On the top of the filter chain there is a message handler class that extends IoHandlerAdapter.

The message handler does some business logic, that is executed in transactional context using Spring Framework's declarative transaction management. After the method implementing the business logic executed and returns the response message, the transaction is committed and the response is sent back to the client.

The problem is when the client is disconnected during executing the transactional method (network problems, etc.) In this scenario the transaction is committed and the server detects the lost connection only when it tries to send out the response message. In our case the transaction should be rolled back.

Can you suggest some way how to detect the connection failure earlier than sending out the message?
There is no way to detect a connection failure. The connection is opened or closed, but you will know only after having successfully sent something to the client.

In other words, you have to implement a kind of two-phases commit in your case :
- receive the request
- make your business transaction
- send the response to the client (at this point, the business transaction is supposed to have been sucessful)
- when the message has been sent, commit the business transaction.


I was afraid of this answer :) Probably we'll need to move from declarative to programmatic transaction handling.

However, even if the response has been sent, you have no way to be sure that your client has read it.


Yes, I'm aware of this, but in our practice it is far more common that a client disconnects during the execution of the business function which can take from few seconds up to few minutes, than disconnecting while sending the response, that can be measured in tenths of seconds or less.

Remember that you are dealing with remote communications, where one of the peer may perfectly disconnect without notice, and you have to deal with this at the protocol level. MINA won't help you here.

Okay, thank you for your response!

Regards,
Andras


We are using Mina 1.1.7.

Regards,
Andras





--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com




Reply via email to