Here is my trick to perform RMI callbacks when client (server is not problematic) is behind a NAT. It's based on keeping RMI client sockets opened, since client behind a NAT has not routable addresses. The solution can be also an alternative to firewalled client environments, where only outgoing connections to popular ports are permitted.
Please read it, and post your ideas,comments,improvements,drawbacks...
Here is an example code, showing the basics:
Middle tier: Remote interface:
Client: Client starts a new thread for the server listener:
Originally posted by Oricio Ocle: Maybe some comments?
Okay, I see what you are doing and I think it's a fine idea. I'm just wondering how I can adapt it to serve 70-80 clients that might connect to one server. I assume I would need to have a differnt mutex to synchonize on (and wait/notify) for each client that wanted to connect and be notified.
The scenario I need to solve is an observer pattern where there are different conditions to whether certain clients should be notified of something. Therefore a single mutex won't work for my case.
But just thinking about it, I can certainly see how I could adapt it to work. Very interesting idea. I'll definitely think more about it.