Re: Processing Streamed Data

Gregg Wonderly <[email protected]>
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
Robert DiFalco wrote:
> I have a large set of data to process, consider say 400,000 records read
> from a database that I want to pass to another machine to build a local
> copy of the data.
>
> I would like the client to make a request for the data and then setup an
> ObjectInputStream to receive the streamed data from the server. The
> server would just create an ObjectOutputStream and write the objects one
> by one, with the client processing them with its ObjectInputStream until
> EOF is hit.
>
> What approach should I take for doing this with RMI, just using sockets
> it would be pretty simple. Is there already an established protocol
> (besides marshalling) that I could use to do this with RMI?

What I have done with streaming applications is have the remote method
return a factory object that is just a serialized object.  Inside of
that object is information to connect back to a socket that the server
has opened for this request.  Also included is a cookie that the client
will pass to the server to authenticate its use of the socket.  The
client can then call a method on the factory to get the stream of data
in whatever format needed.

You can make the input stream return from the remote method call by
having the readObject() method used for deserialization make the socket
connection.

If you really want to optimize the bandwidth use, then you can not use
serialization, but instead optimize the data flow at the bit level.

Gregg Wonderly

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.