Garima Devnani
Garima Devnani

Reputation: 1

Broadcast message to clients using RMI

Can anyone please explain how to implement broadcasting of a message from the server to clients using Java RMI?

I basically want to send a message from the server to all clients.

Upvotes: 0

Views: 1597

Answers (1)

user207421
user207421

Reputation: 311008

  1. The clients needs to export a remote object that is used for callbacks.
  2. Each client needs to register its callback with the server.
  3. The server needs to maintain a collection of these callbacks.
  4. The server needs to iterator over the collection calling each callback.

It's a poor assignment. Quite inappropriate.

  • It isn't obvious how to do it.
  • The server doesn't have a well-defined time to remove a callback from the collection. The client could unregister its callback, but there is no guarantee that it really will before exiting.
  • It will not work at all in the presence of client side firewalls.
  • RMI is a unicast technology, not a broadcast technology.
  • RMI is not well suited to callback architectures.

Upvotes: 1

Related Questions