Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Web service connection  RSS feed

 
Vasily Kukhta
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello!

I am developing a JAX-WS web service using EJB 3.0 and Glassfish application server which receives some information from the clients, performs some buisness methods and saves information to a database.

The service can write information to database only if the connection with the client exists because of necessity of notification of the client about accomplished persisting to a database, and if the connection is lost (for example, because of network failure) all the operations must be rolled back.

So i have the following question: how is it possible to check whether the connection with the client is active?

Thanks a lot in advance!

Vasily
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vasily Kukhta wrote:So i have the following question: how is it possible to check whether the connection with the client is active?


I don't believe that it is possible. The Http Server (or Application Server) hosting the service only detects the lost connection when it attempts to write the HTTP response back to the socket - at that point the code of the Web Method will already have completed.

The "simplest" method to deal with this situation is the transactional client so that the client would obtain the result and a correlation identifier and then acknowledge completion with a second call, specifying the correlation ID, which finally commits the result. If that second call doesn't arrive within a timeout window the result is rolled back.

For (web) services compensating transactions often work better than atomic transactions.
Your Coffee Shop Doesn’t Use Two-Phase Commit (PDF)
SOA Patterns: Compensating Service Transaction
 
Vasily Kukhta
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much! The problem is solved now.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!