Showing posts with label streaming. Show all posts
Showing posts with label streaming. Show all posts

Friday, June 27, 2014

Oracle File Adapter Scalable DOM

I have tried to activate streaming parsing of an xml file with OSB:


this consists in replacing oracle.tip.adapter.file.inbound.FileActivationSpec with oracle.tip.adapter.file.inbound.ScalableFileActivationSpec, and enabling streaming parsing on the File poller Proxy Service. I also set MaxFileAge to 5, to avoid picking up a file before it's completely copied to the Input folder.

I put a SMALL (3 kb file) document 608-12.xml in the input folder, and I get:

Generic Error caught while translating inbound file  in streaming mode  : 608-12.xml
java.lang.NullPointerException
        at oracle.tip.adapter.file.inbound.InboundTranslatorDelegate.xlate(InboundTranslatorDelegate.java:295)
        at oracle.tip.adapter.file.inbound.InboundTranslatorDelegate.doXlate(InboundTranslatorDelegate.java:121)
        at oracle.tip.adapter.file.inbound.ProcessorDelegate.doXlate(ProcessorDelegate.java:388)
        at oracle.tip.adapter.file.inbound.ProcessorDelegate.process(ProcessorDelegate.java:174)
        at oracle.tip.adapter.file.inbound.ProcessWork.run(ProcessWork.java:349)
        at weblogic.work.ContextWrap.run(ContextWrap.java:41)
        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
>



According to Oracle Support KB, this should happen only for HUUUGE documents and in old versions of OSB (we use 11.1.1.5). Related thread on the forum, reporting the same issue, are unanswered.

I am afraid we shall not use this streaming option for the time being.

See also https://community.oracle.com/thread/2195895 (discussion archived without solution...)

Saturday, February 26, 2011

XML Streaming Parsing: a desert populated by skinny animals


Having to implement a XML Streaming parser is no fun these days.

On one hand, you have a solid technology which is JAXB. Wonderful. But it doesn't handle streaming. So if you have a 1 GB document to parse, you are screwed.

On the other hand, you have SAX and StAX.... well I have played a few hours with StAX, and I can't really see the improvement over SAX, apart from the silly "pull" approach over the "push" approach... so what? Basically you still have to handle individual atomic events (startElement, characters, stopElement) and manually reconstruct your Java XmlEntity from them.... painful if you have complex Entities...

StAX is useful only if you need to parse bits and pieces of information here and there, without having to parse the whole thing. Otherwise, FIASCO.


Finally I resorted to using the excellent java.util.Scanner class to locate the start of an element, and read until the end of the element into a String, then use JAXB to parse the String into a XmlEntity.... it works like a charm.

you just need to annotate your entity as @XmlRootElement - no worries you can have multiple XmlRootElement in your file, and you can annotate even a static class.


I see here a big need for a streaming technology that can still make use of JAXB... it seems not too difficult to implement... or some adjustments on StAX so that it can call JAXB...