I have a legacy system where servers get slowly updated over a period of weeks. The hierarchy is such:
1
2
3 4 5
1 is the client pc
2 is a master server
3 4 and 5 are servers across the country.
Currently all of these are sending POJO (plain old java objects) back and forth in an uncompressed format. Think OjbectOutputStream() etc.
I'd like to compress the data being serialized over the wire but do it in such a way that only data being received from a query is compressed. The data being sent down is trivial (query filter data).
Only client #1 and master server #2 are updated right away. Servers #3, #4 and #5 could be updated weeks or months apart from each other. I need a way for the server #2 to be able to detect whether the streams coming back from #3, #4 or #5 are compressed and deal with it accordingly (as they get upgraded).
-EDIT- The solution must be unobtrusive for the servers #3, #4, and #5. These servers do not have the concept of resending the data if an exception occurs.
Here is an example of code used by #2 to communicate with #3, #4, or #5:
// Set the content type to be application/x-java-serialized-object
connection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
setupHeaderAttributes(getHttpHeaders());
setupSessionCookies(getHttpHeaders());
// Load/add httpHeaders
addHeadersToConnection(connection, getHttpHeaders());
// Write the serialized object as post data
objectoutputstream = new ObjectOutputStream(connection.getOutputStream());
objectoutputstream.writeObject(obj);
objectoutputstream.flush();
// Get ready to receive the reply.
inputstream = connection.getInputStream();
setHttpStatus(connection.getResponseCode());
Is this possible? Thank you for your time.
-Dennis