i tried to implement the observerable pattern in rmi the last night. i once worked on a project where we used it for configuration clients (the project was cancelled). no big deal - i said to myself. i implemented it. simple unitTests worked. great !
BUT -yeah a hook- the server dropped the connection of the rmi connection after a short time. never trust simple tests. i tested it with one client. this clients connects to the server, modifies data, observable called client callback, everything seemed ok.
the fact is the rmi connections are dropped after 15 s of inactivity by the server. so the callback in my test was triggered by the same connection. but how can i realize a rmi observable then? i used the vm property sun.rmi.transport.proxy.connectTimeout (more details here). i set the timeout to 10 min. and used a keepalive thread on the client side that calls a simple ping method every 8 min.
this solution has some disadvantages. but in my case - where i have very few connections that should permanently be connected - it is ok.
btw: sun.* packaged properties are not part of the public interface. but i dont expect sun to change this property ever.
good luck to all. and enjoy the summer!
