jetty:http dynamic uri in consumer (from)

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

jetty:http dynamic uri in consumer (from)

paramjyotsingh
1) I have a requirement to expose a REST service POST with uri like http://localhost:9080/boxes/{boxid}

would it be possible to expose this using jetty:http like:

<from uri="jetty:http://localhost:9080/boxes/{boxid} /> i know this doesn;t work it works with restlet


2) In above question i am trying to use jetty:http as it allows custom HttpBinding and I am using custom implementation to close connection and write response for service exposed via camel.

<from uri="restlet:http://localhost:9080/boxes/{boxid}"/>
<to uri="<test-validate-service>"/>
<inOnly uri="seda:background-processing"/>

in this example i am expecting response from validate-service as response for /boxes/{boxid} service and i don;t want it to wait for background processing to complete. But somehow my client connection is not getting closed and at client side and i am not able to process response send by this route.

Please help..
Reply | Threaded
Open this post in threaded view
|

Re: jetty:http dynamic uri in consumer (from)

Willem.Jiang
Administrator
You are sending the InOnly message to seda endpoint.
Can you change it to InOut?


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Friday, May 17, 2013 at 8:38 AM, paramjyotsingh wrote:

> 1) I have a requirement to expose a REST service POST with uri like
> http://localhost:9080/boxes/{boxid}
>  
> would it be possible to expose this using jetty:http like:
>  
> <from uri="jetty:http://localhost:9080/boxes/{boxid} /> i know this doesn;t
> work it works with restlet
>  
>  
> 2) In above question i am trying to use jetty:http as it allows custom
> HttpBinding and I am using custom implementation to close connection and
> write response for service exposed via camel.
>  
> <from uri="restlet:http://localhost:9080/boxes/{boxid}"/>
> <to uri=&quot;&lt;test-validate-service>"/>
> <inOnly uri="seda:background-processing"/>
>  
> in this example i am expecting response from validate-service as response
> for /boxes/{boxid} service and i don;t want it to wait for background
> processing to complete. But somehow my client connection is not getting
> closed and at client side and i am not able to process response send by this
> route.
>  
> Please help..
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/jetty-http-dynamic-uri-in-consumer-from-tp5732691.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).



Reply | Threaded
Open this post in threaded view
|

Re: jetty:http dynamic uri in consumer (from)

paramjyotsingh
This post was updated on .
This is invocation is just trigger to background process and I want to client to wait for this to get completed. That is why i am using inOnly. This part is working fine.

If any of these 2 problems get solved i would be able to get response back as "jetty:http" has httpBinding and i can have custom implementation to close stream after writing response.

One more thing to add, would it work if i add http header "Connection: close" from client side. would it close connection after route has completed processing?

--
Paramjyot Singh
Reply | Threaded
Open this post in threaded view
|

Re: jetty:http dynamic uri in consumer (from)

paramjyotsingh
Update: I tried with http header "Connection: close" from client and it doesn't work.
Reply | Threaded
Open this post in threaded view
|

Re: jetty:http dynamic uri in consumer (from)

Claus Ibsen-2
In reply to this post by paramjyotsingh
Hi

You need to set matchOnUriPrefix=true on the jetty endpoint to have it
match /boxes/***


On Fri, May 17, 2013 at 2:38 AM, paramjyotsingh
<[hidden email]> wrote:

> 1) I have a requirement to expose a REST service POST with uri like
> http://localhost:9080/boxes/{boxid}
>
> would it be possible to expose this using jetty:http like:
>
> <from uri="jetty:http://localhost:9080/boxes/{boxid} /> i know this doesn;t
> work it works with restlet
>
>
> 2) In above question i am trying to use jetty:http as it allows custom
> HttpBinding and I am using custom implementation to close connection and
> write response for service exposed via camel.
>
> <from uri="restlet:http://localhost:9080/boxes/{boxid}"/>
> <to uri=&quot;&lt;test-validate-service>"/>
> <inOnly uri="seda:background-processing"/>
>
> in this example i am expecting response from validate-service as response
> for /boxes/{boxid} service and i don;t want it to wait for background
> processing to complete. But somehow my client connection is not getting
> closed and at client side and i am not able to process response send by this
> route.
>
> Please help..
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/jetty-http-dynamic-uri-in-consumer-from-tp5732691.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

Re: jetty:http dynamic uri in consumer (from)

paramjyotsingh
Hi Claus,

I it does work with 'matchOnUriPrefix' but if i used that i have to do special handling to extract PathParams.

Just to continue with my original problem, i was using restlet as it supports dynamic parameters, for example:-

if my uri on restlet is like http://localhost:9080/boxes/{boxId}|{boxDate}

camel automatically extracts and puts value of 'boxId' and 'boxDate' in Exchange header and no special handling is required. But issue with restlet is that connection is not getting closed when route processing is completed. if i have a route like

<route id="test1">
  <from uri="http://localhost:9080/boxes/{boxId}|{boxDate}" />
  <log message="Box identifer : ${header.boxId} :: ${header.boxDate}" />
  <setBody>
     <simple> Received request for ${header.boxId}</simple>
  </setBody>
  <log message="Route completed" />
</route>

now when i invoke this service suppose with most generic client 'telnet'

I get following log message at camel end:
------
Box identifer : 1234 :: 2013-05-20
Route completed
-------

But on client end(command prompt):
--------
telnet localhost 9080

GET /boxes/1234/2013-05-20 HTTP/1.1


Received request for 1234
---

And connection remains open, i should get something like connection "connection closed by remote host".
I do get this if i use cxfrs or jetty to expose restful service, but it doesn;t work in same way with restlet.

Could you please suggest if something is work with camel-restlet or with restlet library itself.

Thanks and Regards,
Param
Reply | Threaded
Open this post in threaded view
|

Re: jetty:http dynamic uri in consumer (from)

Claus Ibsen-2
Hi

You can maybe send the HTTP header
Connection: Close

To tell the resetlet server to close the connection.
Its a standard HTTP header.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

On Thu, May 23, 2013 at 3:26 AM, paramjyotsingh
<[hidden email]> wrote:

> Hi Claus,
>
> I it does work with 'matchOnUriPrefix' but if i used that i have to do
> special handling to extract PathParams.
>
> Just to continue with my original problem, i was using restlet as it
> supports dynamic parameters, for example:-
>
> if my uri on restlet is like http://localhost:9080/boxes/{boxId}|{boxDate}
>
> camel automatically extracts and puts value of 'boxId' and 'boxDate' in
> Exchange header and no special handling is required. But issue with restlet
> is that connection is not getting closed when route processing is completed.
> if i have a route like
>
> <route id="test1">
>   <from uri="http://localhost:9080/boxes/{boxId}|{boxDate}" />
>   <log message="Box identifer : ${header.boxId} :: ${header.boxDate}" />
>   <setBody>
>      <simple> Received request for ${header.boxId}</simple>
>   </setBody>
>   <log message="Route completed" />
> </route>
>
> now when i invoke this service suppose with most generic client 'telnet'
>
> I get following log message at camel end:
> ------
> Box identifer : 1234 :: 2013-05-20
> Route completed
> -------
>
> But on client end(command prompt):
> --------
> telnet localhost 9080
>
> GET /boxes/1234/2013-05-20 HTTP/1.1
>
>
> Received request for 1234
> ---
>
> And connection remains open, i should get something like connection
> "connection closed by remote host".
> I do get this if i use cxfrs or jetty to expose restful service, but it
> doesn;t work in same way with restlet.
>
> Could you please suggest if something is work with camel-restlet or with
> restlet library itself.
>
> Thanks and Regards,
> Param
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/jetty-http-dynamic-uri-in-consumer-from-tp5732691p5732988.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

Re: jetty:http dynamic uri in consumer (from)

paramjyotsingh
Hi,

I tried with this header but still it is not working.

Thanks and Regards,
Param
Reply | Threaded
Open this post in threaded view
|

Re: jetty:http dynamic uri in consumer (from)

Claus Ibsen-2
Hi

I logged ticket
https://issues.apache.org/jira/browse/CAMEL-6397

To add option reuseAddress to restlet component. Then you can try
configure this to false.

<bean id="reslet" class="org.apache.camel.component.restlet.RestletComponent">
  <property name="reuseAddress" value="false"/>
</bean>



On Fri, May 24, 2013 at 6:24 PM, paramjyotsingh
<[hidden email]> wrote:

> Hi,
>
> I tried with this header but still it is not working.
>
> Thanks and Regards,
> Param
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/jetty-http-dynamic-uri-in-consumer-from-tp5732691p5733131.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen