• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web service connection

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much! The problem is solved now.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic