You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Lakshmi Chaparala <la...@issinc.com> on 2006/03/02 17:14:22 UTC

Axis2 and Streaming

Hi,
I am trying to stream xml back to the client using axis2 implementation. 
Do I have to build OMElement before I stream xml or can I just send XML
across from the server? 

I used XMStreamReader to stream and also set builder caching to false but
axis2 blocks on the call and the client times out before it gets any
response.  

We have to send a large set of xml back to the client and if I build
OMElement, out server's memory jumps really high. I am trying to reduce this
memory footprint by streaming xml as a string and not as an OMElement. Can
this be done? 

Thanks

Lakshmi 





Re: Axis2 and Streaming

Posted by Srinath Perera <he...@gmail.com>.
When you log in and go to the Issue, at the left hand side there is a
link to add a attcachment.  If it do not work send me the attachment
to my mail address

Srinath

On 3/6/06, Lakshmi Chaparala <la...@issinc.com> wrote:
> Hi Srinath,
>
> I opened the following jira issue on XML streaming issue. I am unable to
> attach our JUint test to this jira. I tried sending you the test case in a
> zip file and it does not seem to make it to the mailing list. Our zip file
> is about 900kb. I renamed the extension to test and re-sent it but it still
> failed the delivery. Not sure how I can send our test case to you.
>
>
> Key: AXIS2-483
> URL: http://issues.apache.org/jira/browse/AXIS2-483
> Project: Apache Axis 2.0 (Axis2)
> Type: Bug
> Components: om
> Versions: 0.94
> Environment: Windows XP, JDK 1.5.05
> Reporter: Lakshmi Chaparala
>
> Thanks
>
> Lakshmi
>
> -----Original Message-----
> From: Srinath Perera [mailto:hemapani@gmail.com]
> Sent: Friday, March 03, 2006 5:35 PM
> To: axis-user@ws.apache.org
> Subject: Re: Axis2 and Streaming
>
> go to https://issues.apache.org/jira/secure/Dashboard.jspa, there is a
> signup link there
>
> If it do not work send me the zip file I will create the JIRA
>
> Srinath
>
> On 3/3/06, Lakshmi Chaparala <la...@issinc.com> wrote:
> > Hi Srinath and Ajith,
> >
> > We have a simple JUnit along with Service Impl, lib, data.xml and
> build.xml
> > for streaming issues we have seen so far. I am not sure how to open a JIRA
> > issue in your bug database. Looks like I need an account to do so. We
> would
> > Very much appreciate if you can open a JIRA for it. If not let me know how
> > to do it and I will open an issue. Thank you both for your responses. I
> > tried sending our source files in a zip format and the email could not be
> > delivered to your mail box. How do I send the source back to you?
> >
> > Thanks
> >
> > Lakshmi Chaparala
> > Software Engineer
> > Intelligent Software Solutions
> > Phone:(719)234-0682
> > Email:lakshmi.chaparala@issinc.com
> >
> >
> > -----Original Message-----
> > From: Ajith Ranabahu [mailto:ajith.ranabahu@gmail.com]
> > Sent: Thursday, March 02, 2006 8:22 PM
> > To: axis-user@ws.apache.org
> > Subject: Re: Axis2 and Streaming
> >
> > HI Lakshmi,
> > This is a bug if the streaming is not working. Theoretically we should
> > have the mentioned scenario working without a hitch.  I wonder why
> > Axis2 will hang when trying to create the reader.
> > As Srinath said it would be  helpful if there's a simple test case for
> > us to recreate the problem.
> >
> >
> > --
> > Ajith Ranabahu
> >
> >
> >
> >
>
>
> --
> ============================
> Srinath Perera:
>    http://www.cs.indiana.edu/~hperera/
>    http://www.bloglines.com/blog/hemapani
>
>
>
>


--
============================
Srinath Perera:
   http://www.cs.indiana.edu/~hperera/
   http://www.bloglines.com/blog/hemapani

RE: Axis2 and Streaming

Posted by Lakshmi Chaparala <la...@issinc.com>.
Hi Srinath,

I opened the following jira issue on XML streaming issue. I am unable to
attach our JUint test to this jira. I tried sending you the test case in a
zip file and it does not seem to make it to the mailing list. Our zip file
is about 900kb. I renamed the extension to test and re-sent it but it still
failed the delivery. Not sure how I can send our test case to you.


Key: AXIS2-483
URL: http://issues.apache.org/jira/browse/AXIS2-483
Project: Apache Axis 2.0 (Axis2)
Type: Bug
Components: om
Versions: 0.94
Environment: Windows XP, JDK 1.5.05
Reporter: Lakshmi Chaparala

Thanks

Lakshmi

-----Original Message-----
From: Srinath Perera [mailto:hemapani@gmail.com] 
Sent: Friday, March 03, 2006 5:35 PM
To: axis-user@ws.apache.org
Subject: Re: Axis2 and Streaming

go to https://issues.apache.org/jira/secure/Dashboard.jspa, there is a
signup link there

If it do not work send me the zip file I will create the JIRA

Srinath

On 3/3/06, Lakshmi Chaparala <la...@issinc.com> wrote:
> Hi Srinath and Ajith,
>
> We have a simple JUnit along with Service Impl, lib, data.xml and
build.xml
> for streaming issues we have seen so far. I am not sure how to open a JIRA
> issue in your bug database. Looks like I need an account to do so. We
would
> Very much appreciate if you can open a JIRA for it. If not let me know how
> to do it and I will open an issue. Thank you both for your responses. I
> tried sending our source files in a zip format and the email could not be
> delivered to your mail box. How do I send the source back to you?
>
> Thanks
>
> Lakshmi Chaparala
> Software Engineer
> Intelligent Software Solutions
> Phone:(719)234-0682
> Email:lakshmi.chaparala@issinc.com
>
>
> -----Original Message-----
> From: Ajith Ranabahu [mailto:ajith.ranabahu@gmail.com]
> Sent: Thursday, March 02, 2006 8:22 PM
> To: axis-user@ws.apache.org
> Subject: Re: Axis2 and Streaming
>
> HI Lakshmi,
> This is a bug if the streaming is not working. Theoretically we should
> have the mentioned scenario working without a hitch.  I wonder why
> Axis2 will hang when trying to create the reader.
> As Srinath said it would be  helpful if there's a simple test case for
> us to recreate the problem.
>
>
> --
> Ajith Ranabahu
>
>
>
>


--
============================
Srinath Perera:
   http://www.cs.indiana.edu/~hperera/
   http://www.bloglines.com/blog/hemapani




Re: Axis2 and Streaming

Posted by Srinath Perera <he...@gmail.com>.
go to https://issues.apache.org/jira/secure/Dashboard.jspa, there is a
signup link there

If it do not work send me the zip file I will create the JIRA

Srinath

On 3/3/06, Lakshmi Chaparala <la...@issinc.com> wrote:
> Hi Srinath and Ajith,
>
> We have a simple JUnit along with Service Impl, lib, data.xml and build.xml
> for streaming issues we have seen so far. I am not sure how to open a JIRA
> issue in your bug database. Looks like I need an account to do so. We would
> Very much appreciate if you can open a JIRA for it. If not let me know how
> to do it and I will open an issue. Thank you both for your responses. I
> tried sending our source files in a zip format and the email could not be
> delivered to your mail box. How do I send the source back to you?
>
> Thanks
>
> Lakshmi Chaparala
> Software Engineer
> Intelligent Software Solutions
> Phone:(719)234-0682
> Email:lakshmi.chaparala@issinc.com
>
>
> -----Original Message-----
> From: Ajith Ranabahu [mailto:ajith.ranabahu@gmail.com]
> Sent: Thursday, March 02, 2006 8:22 PM
> To: axis-user@ws.apache.org
> Subject: Re: Axis2 and Streaming
>
> HI Lakshmi,
> This is a bug if the streaming is not working. Theoretically we should
> have the mentioned scenario working without a hitch.  I wonder why
> Axis2 will hang when trying to create the reader.
> As Srinath said it would be  helpful if there's a simple test case for
> us to recreate the problem.
>
>
> --
> Ajith Ranabahu
>
>
>
>


--
============================
Srinath Perera:
   http://www.cs.indiana.edu/~hperera/
   http://www.bloglines.com/blog/hemapani

RE: Axis2 and Streaming

Posted by Lakshmi Chaparala <la...@issinc.com>.
Hi Srinath and Ajith,

We have a simple JUnit along with Service Impl, lib, data.xml and build.xml
for streaming issues we have seen so far. I am not sure how to open a JIRA
issue in your bug database. Looks like I need an account to do so. We would
Very much appreciate if you can open a JIRA for it. If not let me know how
to do it and I will open an issue. Thank you both for your responses. I
tried sending our source files in a zip format and the email could not be
delivered to your mail box. How do I send the source back to you?

Thanks

Lakshmi Chaparala
Software Engineer
Intelligent Software Solutions
Phone:(719)234-0682
Email:lakshmi.chaparala@issinc.com


-----Original Message-----
From: Ajith Ranabahu [mailto:ajith.ranabahu@gmail.com] 
Sent: Thursday, March 02, 2006 8:22 PM
To: axis-user@ws.apache.org
Subject: Re: Axis2 and Streaming

HI Lakshmi,
This is a bug if the streaming is not working. Theoretically we should
have the mentioned scenario working without a hitch.  I wonder why
Axis2 will hang when trying to create the reader.
As Srinath said it would be  helpful if there's a simple test case for
us to recreate the problem.


--
Ajith Ranabahu




Re: Axis2 and Streaming

Posted by Ajith Ranabahu <aj...@gmail.com>.
HI Lakshmi,
This is a bug if the streaming is not working. Theoretically we should
have the mentioned scenario working without a hitch.  I wonder why
Axis2 will hang when trying to create the reader.
As Srinath said it would be  helpful if there's a simple test case for
us to recreate the problem.


--
Ajith Ranabahu

Re: Axis2 and Streaming

Posted by Srinath Perera <he...@gmail.com>.
Hi Lakshmi;

IMO Axis2 should handle this senario, If It do not, I think we have
met a bug. Can you create a simple Junit TestCase for the senario and
open a Jira Issue with it? (bug database)


Use a sample message as a string and remove the thread to simplefy the things
Thanks
Srinath

BTW (did you try to do the things in a one thread)?

Srinath



On 3/2/06, Lakshmi Chaparala <la...@issinc.com> wrote:
> Our Axis2 service is currently implemented as you suggest and the xml is
> streaming back to the client ok.  The problem we're having is that the
> memory footprint on the server is larger than we'd like.
>
> We are creating a large xml result for a query in our Axis2 service
> implementation.  So we end up with a large xml result in a
> ByteArrayOutputStream that we need to send back to the client.  Using the
> standard implementation suggested below doubles the memory footprint on the
> server to create the OMElement that is returned by the service
> implementation method.  We'd like to be able to send the xml we have in
> memory over the wire without creating the OMElment objects.  Even better,
> we'd like to start streaming back the xml result as it is being created.  Is
> there any way to implement an Axis2 service that either has OMElement
> caching off when it streams back to the client or streams a result back to
> the client as it is being created?
>
> The code snippet below illustrates our failed attempts to make this work so
> far:
>
>                 //******* Standard Implementation
>                 final ByteArrayOutputStream os = new
> ByteArrayOutputStream();
>                 //This method simply fills the os with xml
>                 getDataObjectxml(snlModel, requiredAttrs, os);
>                 ByteArrayInputStream bais = new
> ByteArrayInputStream(os.toByteArray());
>                 StAXOMBuilder builder = new StAXOMBuilder(bais);
>                 //Turning off caching causes axis to hang on the retun
>                 //It can't handle a non-caching OMElement
> //                builder.setCache(false);
>                 dataOut = builder.getDocumentElement();
>
>                 //***** Multi-threaded implementation
> //                //set up the streaming connections
> //                final PipedOutputStream pos = new PipedOutputStream();
> //                PipedInputStream pis = new PipedInputStream(pos);
>                 //This implementation hangs here, attempting to create the
> xml stream reader
> //                XMLStreamReader parser =
> XMLInputFactory.newInstance().createXMLStreamReader(pis);
> //                StAXOMBuilder builder = new StAXOMBuilder(parser);
> //                dataOut = builder.getDocumentElement();
> //
> //                //write to the stream on a separate thread
> //                Runnable xmlRunnable = new Runnable() {
> //                    public void run() {
> //                        try {
> //                            getDataObjectxml(snlModel, requiredAttrs,
> pos);
> //                        } catch (Exception e) {
> //                            e.printStackTrace();  //To change body of
> catch statement use File | Settings | File Templates.
> //                        }
> //                    }
> //                };
> //                Thread serializerThread = new Thread(xmlRunnable);
> //                serializerThread.start();
>
>
> Lakshmi Chaparala
>
>
> -----Original Message-----
> From: Srinath Perera [mailto:hemapani@gmail.com]
> Sent: Thursday, March 02, 2006 11:07 AM
> To: axis-user@ws.apache.org
> Subject: Re: Axis2 and Streaming
>
> If you create a OM element as follows by providing a  Stream, the
> stream is not really read
> unless you accsess the OMElement. So If you create a OM element like
> follwoing and use it in Axis2 .. it should do streaming
>
>          File file= new File("line-item.xml");
>          FileInputStream fis= new FileInputStream(file);
>          XMLInputFactory xif= XMLInputFactory.newInstance();
>          XMLStreamReader reader= xif.createXMLStreamReader(fis);
>          StAXOMBuilder builder= new StAXOMBuilder(reader);
>          OMElement lineItem= builder.getDocumentElement();
>
> See http://www-128.ibm.com/developerworks/library/x-axiom/ for more info
>
> --Srinath
>
>
>
>


--
============================
Srinath Perera:
   http://www.cs.indiana.edu/~hperera/
   http://www.bloglines.com/blog/hemapani

RE: Axis2 and Streaming

Posted by Lakshmi Chaparala <la...@issinc.com>.
Our Axis2 service is currently implemented as you suggest and the xml is
streaming back to the client ok.  The problem we're having is that the
memory footprint on the server is larger than we'd like.

We are creating a large xml result for a query in our Axis2 service
implementation.  So we end up with a large xml result in a
ByteArrayOutputStream that we need to send back to the client.  Using the
standard implementation suggested below doubles the memory footprint on the
server to create the OMElement that is returned by the service
implementation method.  We'd like to be able to send the xml we have in
memory over the wire without creating the OMElment objects.  Even better,
we'd like to start streaming back the xml result as it is being created.  Is
there any way to implement an Axis2 service that either has OMElement
caching off when it streams back to the client or streams a result back to
the client as it is being created?

The code snippet below illustrates our failed attempts to make this work so
far:

                //******* Standard Implementation
                final ByteArrayOutputStream os = new
ByteArrayOutputStream();
                //This method simply fills the os with xml
                getDataObjectxml(snlModel, requiredAttrs, os);
                ByteArrayInputStream bais = new
ByteArrayInputStream(os.toByteArray());
                StAXOMBuilder builder = new StAXOMBuilder(bais);
                //Turning off caching causes axis to hang on the retun
                //It can't handle a non-caching OMElement
//                builder.setCache(false); 
                dataOut = builder.getDocumentElement();
                
                //***** Multi-threaded implementation
//                //set up the streaming connections
//                final PipedOutputStream pos = new PipedOutputStream();
//                PipedInputStream pis = new PipedInputStream(pos);
                //This implementation hangs here, attempting to create the
xml stream reader
//                XMLStreamReader parser =
XMLInputFactory.newInstance().createXMLStreamReader(pis);
//                StAXOMBuilder builder = new StAXOMBuilder(parser);
//                dataOut = builder.getDocumentElement();
//                
//                //write to the stream on a separate thread
//                Runnable xmlRunnable = new Runnable() {
//                    public void run() {
//                        try {
//                            getDataObjectxml(snlModel, requiredAttrs,
pos);
//                        } catch (Exception e) {
//                            e.printStackTrace();  //To change body of
catch statement use File | Settings | File Templates.
//                        }
//                    }
//                };
//                Thread serializerThread = new Thread(xmlRunnable);
//                serializerThread.start();


Lakshmi Chaparala


-----Original Message-----
From: Srinath Perera [mailto:hemapani@gmail.com] 
Sent: Thursday, March 02, 2006 11:07 AM
To: axis-user@ws.apache.org
Subject: Re: Axis2 and Streaming

If you create a OM element as follows by providing a  Stream, the
stream is not really read
unless you accsess the OMElement. So If you create a OM element like
follwoing and use it in Axis2 .. it should do streaming

         File file= new File("line-item.xml");
         FileInputStream fis= new FileInputStream(file);
         XMLInputFactory xif= XMLInputFactory.newInstance();
         XMLStreamReader reader= xif.createXMLStreamReader(fis);
         StAXOMBuilder builder= new StAXOMBuilder(reader);
         OMElement lineItem= builder.getDocumentElement();

See http://www-128.ibm.com/developerworks/library/x-axiom/ for more info

--Srinath




Re: Axis2 and Streaming

Posted by Srinath Perera <he...@gmail.com>.
If you create a OM element as follows by providing a  Stream, the
stream is not really read
unless you accsess the OMElement. So If you create a OM element like
follwoing and use it in Axis2 .. it should do streaming

         File file= new File("line-item.xml");
         FileInputStream fis= new FileInputStream(file);
         XMLInputFactory xif= XMLInputFactory.newInstance();
         XMLStreamReader reader= xif.createXMLStreamReader(fis);
         StAXOMBuilder builder= new StAXOMBuilder(reader);
         OMElement lineItem= builder.getDocumentElement();

See http://www-128.ibm.com/developerworks/library/x-axiom/ for more info

--Srinath

Re: Axis2 and Streaming

Posted by Srinath Perera <he...@gmail.com>.
If you create a new OMElement

File file= new File("line-item.xml");
         FileInputStream fis= new FileInputStream(file);
         XMLInputFactory xif= XMLInputFactory.newInstance();
         XMLStreamReader reader= xif.createXMLStreamReader(fis);
        StAXOMBuilder builder= new StAXOMBuilder(reader);
         lineItem= builder.getDocumentElement();


On 3/2/06, Lakshmi Chaparala <la...@issinc.com> wrote:
> Hi,
> I am trying to stream xml back to the client using axis2 implementation.
> Do I have to build OMElement before I stream xml or can I just send XML
> across from the server?
>
> I used XMStreamReader to stream and also set builder caching to false but
> axis2 blocks on the call and the client times out before it gets any
> response.
>
> We have to send a large set of xml back to the client and if I build
> OMElement, out server's memory jumps really high. I am trying to reduce this
> memory footprint by streaming xml as a string and not as an OMElement. Can
> this be done?
>
> Thanks
>
> Lakshmi
>
>
>
>
>


--
============================
Srinath Perera:
   http://www.cs.indiana.edu/~hperera/
   http://www.bloglines.com/blog/hemapani