File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JBoss/WildFly and the fly likes Detect Client Shutdown Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Detect Client Shutdown" Watch "Detect Client Shutdown" New topic
Author

Detect Client Shutdown

Josh Britton
Greenhorn

Joined: Nov 26, 2008
Posts: 24
Hi. I am an EJB/JBoss newbie trying to develop a server app with multiple clients. The client app (launched with WebStart) uses both jms and rmi to communicate with the server app. All of my ejbs are stateless. I only want to allow a client to be logged in, er, 'once at a time.' In other words, if a client is logged on one machine, that client should not be able to log in elsewhere. So when a client logs in, I set a boolean in the db and the client cannot log in elsewhere until that boolean changes.

My question is: what is the best way to detect client connection failure? For example, the client's power fails, or the client's internet connection dies? Is there a built-in way to listen for such disconnects in JBoss, or do I need to set up my own periodic ping from the server app to ensure client's are still 'alive?'

Thanks,

Josh
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
I think you should use a Stateful session bean to manage that, then implement a listener to the session timeout of the bean and/or in the preDestroyed method to remove the flag. So if user is disconnected unexpectedly, then longest time they have to wait is the session timeout.


“Everything should be as simple as it is, but not simpler.” Albert Einstein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Detect Client Shutdown