I am not an expert in RMI, but I can say that you can search for the book "Java Network Programming and Distributed Computing" by "David and Michael Reilley". You can find a great RMI CALLBACK implementation example that starts on page 278!
The author defines a good way to understand this, so I'd rather copy / paste than try to make my own, here it is:
- "The easiest way to understand the callback is to think about a phone call. Suppose you want to know if the stock price has reached a certain level, and ask your broker to call back when this happens. When the broker (event source) notices that the stock price reflects your parameters , he or she calls you to notify you of a new price. This is a callback.
In the default implementation, RMI allows only communication between the CLIENT and SERVER, requesting the actions of remote services (remote objects) on the server host. You can use the callback method than to have your server access your client!
Thoroughly! Imagine if you have ONE server that you want to check if it is on the network (or if it did not fall / turn off), called the client! You will need to request continuous use of the remote object, which should return some logical value (for example) that actually speaks on the Internet.
That would be awful! As you lose some network bandwidth, ask the server again, and again, and again ... causing some connection pools on it!
This should be useful, in these cases use CALLBACK; -)
I hope you with my answer will understand a little what callback is.
Respectfully,
source share