This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

input from process invoked via RMI  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i'm writing a client-server application using RMI. the client presses a button which invokes a remote method which creates a process on the server side using Runtime.exec(). now i need to get the output from the process (standard output) and send it back to the client while it's being written. the idea is to keep the client updated on the process status.

any ideas...i don't think serializing an InputStream will work...right?

by the way, i'm relatively new at Java.

thank you!
 
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, an InputStream isn't serialiazable, but the data inside it is. Assuming that the data being returned from your Process is character data, you can wrap the InputStream in an InputStreamReader, the a BufferedReader, and use readLine() to get the output from the process as a series of Strings. You could also just read byte[]s directly from the InputStream and return those, too, but I'm assuming it's going to be turned into Strings sooner or later.

Another idea to keep in mind is the length of time it takes for the process to execute... do you want to call one method and get the results as a return value after it's finished? Or do you want to make an interface for the client to send to the server, and have the server send pieces of data to the client when they are available?
 
Bartender
Posts: 19731
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, it sounds like you want a progress callback. I use one in a process that can span literally days. It's defined as an interface that gets implemented in one of the remote client classes.

There's some pretty decent docs on RMI callbacks, but I forget where. I just googled for them when I needed them.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!