0

In my weblogic server (4 nodes) I defined a migratable JMS Server with (Oracle) Database Storage. Here I receive 1000 messages per second. Every message is an XML message of about 1kB.

I might have the need to stop the java MDB for 1 day and store several GB of data (due to maintenance).

how can I (with little overhead) save these messages compressed in order to reduce the space?

giusy
  • 365
  • 2
  • 5
  • 17

1 Answers1

1

There are 2 possibilities, but generally speaking the main idea is to compress data:

  1. compress message: suggested by oracle
  2. compress TableSpace; not suggetsed by Oracle

then let me suggest the first solution; then, you can enable weblogic compression or your custom compression on producer and consumer.

Weblogic compression

Navigate to JMS Connection Factory -> Click the Configuration > Default Delivery tab. On the Default Delivery page -> Default Compression Threshold

Custom GZIP Compression

  • compress xml message before sending
  • uncompress when you receive

for instance I use the following code on MDB to extract text if the producer compressed message or not;

   protected String getText(Message message) throws JMSException, IOException {
    if (message instanceof TextMessage) {
        return ((TextMessage) message).getText();
    } else if (message instanceof BytesMessage) {
        byte zipped[] = new byte[(int) ((BytesMessage) message)
                .getBodyLength()];
        ((BytesMessage) message).readBytes(zipped);
        ByteArrayInputStream bais = new ByteArrayInputStream(zipped);
        StringBuilder sb = null;
        GZIPInputStream in = null;
        try {
            in = new GZIPInputStream(bais);
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(in));
            sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }
        } finally {
            try {
                if (in != null)
                    in.close();
            } catch (IOException e) {
                log.error("getText: ", e);
            }
            try {
                if (bais != null)
                    bais.close();
            } catch (IOException e) {
                log.error("getText: ", e);
            }
        }
        return sb.toString();
    } else {
        throw new JMSException("Unrecognized message type "
                + message.getClass());
    }
} 

Custom EXI Compression

Recently I evalued the Efficient XML Interchange (EXI) Format 1.0. Here the indicators:

  • original message: 8903B
  • gzipped message: 1212B
  • exi schemaless: 903B
  • exi with schema: 856B

but the only java open source implementation is the exi proxessor proposed by siemens

venergiac
  • 7,469
  • 2
  • 48
  • 70