Forums Register Login

Handling CallBack or Broadcast in RMI

+Pie Number of slices to send: Send
Hi,

I'm just jumping around RMI classes till I get my programming assignment.

I've a doubt regarding the handling of CallBack or Broadcast mechanisms in RMI client server environment. I can always inform (pass a message) to server from client but when it comes to the server to inform something to client, my thread slows down
e.g. If I want to broadcast a message "server going down" to all the clients connected to it. Basically I'm looking for a mechanism of calling a client's method from server by passing some message object.

I couldn't find a definitive, commonly used approach for this. I finally implemented a thread mechanism in which a client thread is constantly locked into the Server till some message appears in the server Q for broadcasting. And then the method returns to client with the message and then again gets locked with server. But then it was getting complex and risky with all the use-cases coming together.

Instead I'm more interested in knowing if there is any traditional, more sophisticated mechanism already available in Java RMI world?

I browsed though the SCJD topics but couldn't find anything which is classical.

Thanks in advance,
Swapnil
+Pie Number of slices to send: Send
I found an approach here which achieves this...
Using RMI with Client-Side Callbacks

and

An in-depth look at RMI callbacks

In this they suggest to expose client side object on an anonymous port.
Secret lies in
http://java.sun.com/j2se/1.4.2/docs/api/java/rmi/server/UnicastRemoteObject.html#exportObject

Its really easy.
+Pie Number of slices to send: Send
Hi Swapnil,

Another useful article, which includes information on client-side callbacks, is Sun's jGuru: Remote Method Invocation (RMI) article.

Regards, Andrew

P.S. Yes, this is easy to do. However when you get your assignment you will find that you will not get any extra marks for going beyond the specifications (and there is no need for you to update all the clients when shutting down the server or when a different client makes a booking).
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2138 times.
Similar Threads
How to get feedback from lock()
Locking
Callback in SCJD Assignment
FBN: changing lock method's IOException
Create/Update Method Synchronization
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:39:41.