You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by yogu13 <yo...@synechron.com> on 2013/03/27 09:06:11 UTC

using Camel-Servlet component to consume application/xml message

Hi,Wanted to know if i can use Camel-Servlet to consume a HTTP message having
content type as "text/xml" within which the payload has an xml ...my route
configuration is as a below        											     	the HTTP request when
intercepted looks as followsPOST /sampleMessageHandler/camel/CamelServlet
HTTP/1.1Connection: closeContent-Type: text/xmlContent-Length: 145Host:
localhost:9000User-Agent: Apache-HttpClient/4.2.3 (java 1.5)<?xml
version="1.0"?>ToveJaniReminderDon't forget me this weekend!Please let me
know if i can use camel-servlet for this.Regards,-Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/using-Camel-Servlet-component-to-consume-application-xml-message-tp5729904.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: using Camel-Servlet component to consume application/xml message

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can configure the jms endpoint with jmsMessageType=Bytes

That tells Camel to force and use a javax.jmx.BytesMessage for the JMS message.
Then you dont need to convert the message beforehand.

And mind about stream caching for big payloads. The http component
forces using that
http://camel.apache.org/stream-caching.html

It overflows to disk when its > 64KB. So I suggest in your case set
set a higher threadshold with
CamelCachedOutputStreamThreshold

So it wont overflow to disk.



On Wed, Mar 27, 2013 at 11:49 AM, yogu13 <yo...@synechron.com> wrote:
> Hello Claus,
>
> We are converting the text message into bytes because an issue with
> ActiveMQ... ActiveMQ text message have a restriction on payload size
> shouldnt be greater than 64K as they use the API DataOutputStream.writeUTF8
> which has this restriction. I have logged it on to their forums but not much
> help there :( the link for the same is ->
> http://activemq.2283324.n4.nabble.com/ActiveMQ-5-8-0-Issue-with-HTTP-Connector-td4664876.html
>
>
> Let me check with tracer and see i am able to zero down on the isssue here..
>
> Thanks for the pointers claus.. Appreciate it..
>
> Regards.
> -Yogesh
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/using-Camel-Servlet-component-to-consume-text-xml-message-tp5729904p5729920.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: using Camel-Servlet component to consume application/xml message

Posted by yogu13 <yo...@synechron.com>.
Hello Claus,

We are converting the text message into bytes because an issue with
ActiveMQ... ActiveMQ text message have a restriction on payload size
shouldnt be greater than 64K as they use the API DataOutputStream.writeUTF8
which has this restriction. I have logged it on to their forums but not much
help there :( the link for the same is ->
http://activemq.2283324.n4.nabble.com/ActiveMQ-5-8-0-Issue-with-HTTP-Connector-td4664876.html


Let me check with tracer and see i am able to zero down on the isssue here..

Thanks for the pointers claus.. Appreciate it..

Regards.
-Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/using-Camel-Servlet-component-to-consume-text-xml-message-tp5729904p5729920.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: using Camel-Servlet component to consume application/xml message

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 27, 2013 at 11:17 AM, yogu13 <yo...@synechron.com> wrote:
> Hi Claus.
>
> Thanks for your time..so based on the above route .. i should have seen the
> JMS message having the byte payload of the XML but that doesnt happen.
>
> As i understand from the class
> https://svn.apache.org/repos/asf/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
> it doesnt set the body of the message into exchange hence the JMS message
> payload is empty.
>
> Is my understanding right here?
>

Use the tracer to see what happens.
http://camel.apache.org/tracer

The type conversion to byte[] should contain some data.

And mind that if you send a bytes jms message, then you cannot often
view that in a JMS console. Its not human readable. If you use a Text
message instead, then you can view the XML in a JMS console.

And why do you want to use byte[] when the data is text based, and a
javax.jms.TextMessage type is a better fit?

> Regards,
> -Yogesh
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/using-Camel-Servlet-component-to-consume-text-xml-message-tp5729904p5729914.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: using Camel-Servlet component to consume application/xml message

Posted by yogu13 <yo...@synechron.com>.
Hi Claus.

Thanks for your time..so based on the above route .. i should have seen the
JMS message having the byte payload of the XML but that doesnt happen.

As i understand from the class
https://svn.apache.org/repos/asf/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
it doesnt set the body of the message into exchange hence the JMS message
payload is empty.

Is my understanding right here?

Regards,
-Yogesh




--
View this message in context: http://camel.465427.n5.nabble.com/using-Camel-Servlet-component-to-consume-text-xml-message-tp5729904p5729914.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: using Camel-Servlet component to consume application/xml message

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yes the servlet component can support any kind of data the servlet
container can handle. eg that is HTTP.
Usually the caller sets the "Content-Type" header with a value of
"text/xml" to tell you that the http body is xml based.


On Wed, Mar 27, 2013 at 9:06 AM, yogu13 <yo...@synechron.com> wrote:
> Hi,Wanted to know if i can use Camel-Servlet to consume a HTTP message having
> content type as "text/xml" within which the payload has an xml ...my route
> configuration is as a below                                                                                                     the HTTP request when
> intercepted looks as followsPOST /sampleMessageHandler/camel/CamelServlet
> HTTP/1.1Connection: closeContent-Type: text/xmlContent-Length: 145Host:
> localhost:9000User-Agent: Apache-HttpClient/4.2.3 (java 1.5)<?xml
> version="1.0"?>ToveJaniReminderDon't forget me this weekend!Please let me
> know if i can use camel-servlet for this.Regards,-Yogesh
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/using-Camel-Servlet-component-to-consume-application-xml-message-tp5729904.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen