You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by greenstar <jn...@gmail.com> on 2010/03/29 04:10:32 UTC

Help with onCompletion()

Consider the following "simple" route:

        from("jetty:http://0.0.0.0:8089/test/rest?matchOnUriPrefix=true")
        .onCompletion()
        .to("log:sync")
        .end()
       
.to("http://localhost:8099?throwExceptionOnFailure=false&bridgeEndpoint=true");

With tracing enabled, the following log occurs when the http endpoint is hit
with curl.  (I've numbered the entries so I can refer to them in my comments
below).

1)
Mar 28, 2010 6:28:44 PM org.apache.camel.processor.Logger process
INFO: 50ec6397-c4b5-4837-b642-86ae563a6b6c >>> ()
from(http://0.0.0.0:8089/test/rest) -->  <<< Pattern:InOut,
Headers:{Host=localhost:8089,
CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
CamelHttpUri=/test/rest/v1/ping, CamelHttpPath=/test/rest/v1/ping,
CamelHttpCharacterEncoding=null, CamelHttpQuery=null, Content-Type=null,
CamelHttpMethod=GET, User-Agent=curl/7.19.7 (i386-apple-darwin10.2.0)
libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3, Accept=*/*}, BodyType:null,
Body:null

2)
Mar 28, 2010 6:28:44 PM org.apache.camel.processor.Logger process
INFO: 50ec6397-c4b5-4837-b642-86ae563a6b6c >>> (route1)
from(http://0.0.0.0:8089/test/rest) --> http://localhost:8099 <<<
Pattern:InOut,
Headers:{CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
CamelHttpCharacterEncoding=null, CamelHttpQuery=null, Host=localhost:8089,
User-Agent=curl/7.19.7 (i386-apple-darwin10.2.0) libcurl/7.19.7
OpenSSL/0.9.8l zlib/1.2.3, CamelHttpMethod=GET,
CamelHttpPath=/test/rest/v1/ping, CamelHttpUri=/test/rest/v1/ping,
Accept=*/*, Content-Type=null}, BodyType:null, Body:null
Mar 28, 2010 6:28:57 PM org.apache.camel.processor.Logger process

3)
INFO: 50ec6397-c4b5-4837-b642-86ae563a6b6c >>> (route1)
from(http://0.0.0.0:8089/test/rest) --> http://localhost:8099 <<<  (OUT),
Pattern:InOut, Headers:{Content-Type=text/plain,
CamelHttpPath=/test/rest/v1/ping,
CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
Transfer-Encoding=chunked, CamelHttpUri=/test/rest/v1/ping,
CamelHttpMethod=GET, CamelHttpResponseCode=200, Cache-Control=private,
x-gzip-ok="", Host=localhost:8089, CamelHttpQuery=null, X-XSS-Protection=0,
CamelHttpCharacterEncoding=null, Accept=*/*, Date=Mon, 29 Mar 2010 01:28:58
GMT, Server=Google Frontend, User-Agent=curl/7.19.7
(i386-apple-darwin10.2.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3},
BodyType:null, Body:null, OutBodyType:java.io.ByteArrayInputStream,
OutBody:PONG
Mar 28, 2010 6:28:57 PM org.apache.camel.processor.Logger process

4)
INFO: 1b363ae4-1e94-409f-bef4-5ba76b163f3e >>> (route1)
OnCompletion[50ec6397-c4b5-4837-b642-86ae563a6b6c] --> log://sync <<< 
(OUT), Pattern:InOnly, Headers:{User-Agent=curl/7.19.7
(i386-apple-darwin10.2.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3,
Content-Type=null, CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
CamelHttpPath=/test/rest/v1/ping, Accept=*/*, CamelHttpMethod=GET,
CamelHttpUri=/test/rest/v1/ping, CamelHttpQuery=null,
CamelHttpCharacterEncoding=null, Host=localhost:8089}, BodyType:null,
Body:null, OutBodyType:org.apache.camel.converter.stream.InputStreamCache,
OutBody:

5)
Mar 28, 2010 6:28:57 PM org.apache.camel.processor.Logger process
INFO: Exchange[BodyType:null, Body:null]

6)
Mar 28, 2010 6:28:57 PM org.apache.camel.processor.Logger process
INFO: 1b363ae4-1e94-409f-bef4-5ba76b163f3e >>> (route1)
OnCompletion[50ec6397-c4b5-4837-b642-86ae563a6b6c] --> log://sync <<< 
(OUT), Pattern:InOnly, Headers:{User-Agent=curl/7.19.7
(i386-apple-darwin10.2.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3,
Content-Type=null, CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
CamelHttpPath=/test/rest/v1/ping, Accept=*/*, CamelHttpMethod=GET,
CamelHttpUri=/test/rest/v1/ping, CamelHttpQuery=null,
CamelHttpCharacterEncoding=null, Host=localhost:8089}, BodyType:null,
Body:null, OutBodyType:org.apache.camel.converter.stream.InputStreamCache,
OutBody:PONG

---

I understand entries 2 and 3, (the IN and OUT of the main route).  However I
have a number of questions on the others:

a) What is entry 1 representing (and why does it have an "empty" to()
endpoint)?
b) Why are their two log entries for the onCompletion portion (4 and 6)?  I
notice that one contains the outBody (PONG) and the other does not.
c) I want to add a predicate for onComplete based on
Exchange.HTTP_RESPONSE_CODE.  This is in the regular response (3), but it
doesn't appear in any of the onCompletion entries, so how do I make
decisions based on this?

Thanks
-- 
View this message in context: http://old.nabble.com/Help-with-onCompletion%28%29-tp28064287p28064287.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Help with onCompletion()

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

There is a couple of tickets in JIRA about fixing/improving tracer.
Especially with those onXXX and interceptor which makes it more
complex to trace the exchange at runtime.



On Mon, Mar 29, 2010 at 4:10 AM, greenstar <jn...@gmail.com> wrote:
>
> Consider the following "simple" route:
>
>        from("jetty:http://0.0.0.0:8089/test/rest?matchOnUriPrefix=true")
>        .onCompletion()
>        .to("log:sync")
>        .end()
>
> .to("http://localhost:8099?throwExceptionOnFailure=false&bridgeEndpoint=true");
>
> With tracing enabled, the following log occurs when the http endpoint is hit
> with curl.  (I've numbered the entries so I can refer to them in my comments
> below).
>
> 1)
> Mar 28, 2010 6:28:44 PM org.apache.camel.processor.Logger process
> INFO: 50ec6397-c4b5-4837-b642-86ae563a6b6c >>> ()
> from(http://0.0.0.0:8089/test/rest) -->  <<< Pattern:InOut,
> Headers:{Host=localhost:8089,
> CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
> CamelHttpUri=/test/rest/v1/ping, CamelHttpPath=/test/rest/v1/ping,
> CamelHttpCharacterEncoding=null, CamelHttpQuery=null, Content-Type=null,
> CamelHttpMethod=GET, User-Agent=curl/7.19.7 (i386-apple-darwin10.2.0)
> libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3, Accept=*/*}, BodyType:null,
> Body:null
>
> 2)
> Mar 28, 2010 6:28:44 PM org.apache.camel.processor.Logger process
> INFO: 50ec6397-c4b5-4837-b642-86ae563a6b6c >>> (route1)
> from(http://0.0.0.0:8089/test/rest) --> http://localhost:8099 <<<
> Pattern:InOut,
> Headers:{CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
> CamelHttpCharacterEncoding=null, CamelHttpQuery=null, Host=localhost:8089,
> User-Agent=curl/7.19.7 (i386-apple-darwin10.2.0) libcurl/7.19.7
> OpenSSL/0.9.8l zlib/1.2.3, CamelHttpMethod=GET,
> CamelHttpPath=/test/rest/v1/ping, CamelHttpUri=/test/rest/v1/ping,
> Accept=*/*, Content-Type=null}, BodyType:null, Body:null
> Mar 28, 2010 6:28:57 PM org.apache.camel.processor.Logger process
>
> 3)
> INFO: 50ec6397-c4b5-4837-b642-86ae563a6b6c >>> (route1)
> from(http://0.0.0.0:8089/test/rest) --> http://localhost:8099 <<<  (OUT),
> Pattern:InOut, Headers:{Content-Type=text/plain,
> CamelHttpPath=/test/rest/v1/ping,
> CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
> Transfer-Encoding=chunked, CamelHttpUri=/test/rest/v1/ping,
> CamelHttpMethod=GET, CamelHttpResponseCode=200, Cache-Control=private,
> x-gzip-ok="", Host=localhost:8089, CamelHttpQuery=null, X-XSS-Protection=0,
> CamelHttpCharacterEncoding=null, Accept=*/*, Date=Mon, 29 Mar 2010 01:28:58
> GMT, Server=Google Frontend, User-Agent=curl/7.19.7
> (i386-apple-darwin10.2.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3},
> BodyType:null, Body:null, OutBodyType:java.io.ByteArrayInputStream,
> OutBody:PONG
> Mar 28, 2010 6:28:57 PM org.apache.camel.processor.Logger process
>
> 4)
> INFO: 1b363ae4-1e94-409f-bef4-5ba76b163f3e >>> (route1)
> OnCompletion[50ec6397-c4b5-4837-b642-86ae563a6b6c] --> log://sync <<<
> (OUT), Pattern:InOnly, Headers:{User-Agent=curl/7.19.7
> (i386-apple-darwin10.2.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3,
> Content-Type=null, CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
> CamelHttpPath=/test/rest/v1/ping, Accept=*/*, CamelHttpMethod=GET,
> CamelHttpUri=/test/rest/v1/ping, CamelHttpQuery=null,
> CamelHttpCharacterEncoding=null, Host=localhost:8089}, BodyType:null,
> Body:null, OutBodyType:org.apache.camel.converter.stream.InputStreamCache,
> OutBody:
>
> 5)
> Mar 28, 2010 6:28:57 PM org.apache.camel.processor.Logger process
> INFO: Exchange[BodyType:null, Body:null]
>
> 6)
> Mar 28, 2010 6:28:57 PM org.apache.camel.processor.Logger process
> INFO: 1b363ae4-1e94-409f-bef4-5ba76b163f3e >>> (route1)
> OnCompletion[50ec6397-c4b5-4837-b642-86ae563a6b6c] --> log://sync <<<
> (OUT), Pattern:InOnly, Headers:{User-Agent=curl/7.19.7
> (i386-apple-darwin10.2.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3,
> Content-Type=null, CamelHttpUrl=http://localhost:8089/test/rest/v1/ping,
> CamelHttpPath=/test/rest/v1/ping, Accept=*/*, CamelHttpMethod=GET,
> CamelHttpUri=/test/rest/v1/ping, CamelHttpQuery=null,
> CamelHttpCharacterEncoding=null, Host=localhost:8089}, BodyType:null,
> Body:null, OutBodyType:org.apache.camel.converter.stream.InputStreamCache,
> OutBody:PONG
>
> ---
>
> I understand entries 2 and 3, (the IN and OUT of the main route).  However I
> have a number of questions on the others:
>
> a) What is entry 1 representing (and why does it have an "empty" to()
> endpoint)?
> b) Why are their two log entries for the onCompletion portion (4 and 6)?  I
> notice that one contains the outBody (PONG) and the other does not.
> c) I want to add a predicate for onComplete based on
> Exchange.HTTP_RESPONSE_CODE.  This is in the regular response (3), but it
> doesn't appear in any of the onCompletion entries, so how do I make
> decisions based on this?
>
> Thanks
> --
> View this message in context: http://old.nabble.com/Help-with-onCompletion%28%29-tp28064287p28064287.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus