Forums Register Login

Serialization Prob in RMI

+Pie Number of slices to send: Send
Hi,
I am writting a chat server application. So I wrote an Interface for the RMI Server and it has all the methods like
public Message getMessage()
public void setMessage(Message m)
Now on the client side I am using a thread to get all the mesgs from the server every miliseconds...so even if there is no acitivity on the server ..the thread is taking lots of system resources. Now I want to do something that will directly send messages to client from the RMI.
So now the question is ...
"Is that possible for the RMI Server to communicate with all the clients ? " If yes then how ?

thanks
Pratik
+Pie Number of slices to send: Send
One way: your server object could allow clients to register as listeners, and treat the messages back out to the clients as events:

Your implementation object should include a private method such as fireClientMessage() that iterates through the collection of listeners and invokes a function supported by ClientListener (and implemented by every Client).

Or something like that. I would design it so that the client exports a Remote interface to the Server side, but I'm evil like that.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
[This message has been edited by Michael Ernest (edited October 15, 2001).]
+Pie Number of slices to send: Send
Thanks for your reply. But I have difficulties regestering the clients as Listeners...
I have a client which has a thread running in it and which fetched the messages from the RMI server... how should I register the client as a listener...

I'd appriciate if you could elaborate more on that

thanks
Pratik
+Pie Number of slices to send: Send
I can, but not from memory. At home I have a design for a distributed messaging system, from which I could jot down the interfaces needed to do this either point-to-point or publish-subscribe.
I'll get it up on this thread as soon as I get a chance. Patience, please.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
+Pie Number of slices to send: Send
If you could do so then I would really appriciate your help !!
Looking forward to hear from you !!

thanks in advance
Pratik
+Pie Number of slices to send: Send
Hi I am waiting for you to explain me about RMI issues plus I would also like for you to let me know about any good RMI resources on the net.
I am still stuck with that problem. So I am really waiting for yuor help.

thanks
Pratik
+Pie Number of slices to send: Send
Let me sketch out the basic elements and let's see where it takes you:
The roles to define for a remote event notification scheme:
Publisher -- server-side agent that produces events
--> requires an EventService to be constructed
Subscriber -- describes client
--> extends Remote
--> inform(Event evt)
--> concrete class has a Subscription
EventServiceInterface -- exchange btwn Subscriber/Publisher
--> extends Remote
--> publish(Event evt)
--> subscribe(Event evt, Filter flt, Subscriber sub)
--> unsubscribe(Event evt, Filter flt, Subscriber sub)
EventService
--> extends UnicastRemoteObject
--> implements EventServiceInterface
client-side: an EventServiceProxy
--> performs Naming.lookup()
--> encapsulates remote calls to publish/subscribe/unsubscribe
Subscription
--> a collection of Subscribers for a particular event type
--> optionally, has a Filter collection to refine the event list
Filter
--> remote service available to client
--> apply(Event evt):: boolean

------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
Bras cause cancer. And tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1129 times.
Similar Threads
Client server Starting Order?
About server auto release
threads in a distributed application
message from server
RMI server send message to client
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:43:17.