You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "maxence.dewil" <th...@gmail.com> on 2012/11/16 11:25:10 UTC

doCatch returns null

Hi,

tested with camel 2.10.1 and 2.10.2 :

*When I turn the route :*

from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
.process(new Processor() {
    @Override
    public void process(Exchange exchange) throws Exception {
       exchange.getOut().setBody(new Output());
    }});

*into :*

from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
.doTry()
    .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
           throw new IllegalStateException();
        }});			
.doCatch(IllegalStateException.class)
    .process(new Processor() {
	@Override
        public void process(Exchange exchange) throws Exception {
            exchange.getOut().setBody(new Output());
        }});
.end();

*Then the response body of myWebService is empty.*

Is it possible that my route returns something in a doCatch() ?

Any help would be appreciated



--
View this message in context: http://camel.465427.n5.nabble.com/doCatch-returns-null-tp5722851.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: doCatch returns null

Posted by "maxence.dewil" <th...@gmail.com>.
JIRA ticket:  https://issues.apache.org/jira/browse/CAMEL-5810
<https://issues.apache.org/jira/browse/CAMEL-5810>  



--
View this message in context: http://camel.465427.n5.nabble.com/doCatch-returns-null-tp5722851p5723012.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: doCatch returns null

Posted by "maxence.dewil" <th...@gmail.com>.
Hi again,

I solved the problem by changing my route to this:

from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
*.recipientList(simple("direct:${header.operationName}"));*

*from("direct:myOperation")*
  .doTry()
    .process(new Processor() {
       @Override
        public void process(Exchange exchange) throws Exception {
           throw new IllegalStateException();
        }});
  .doCatch(IllegalStateException.class)
    .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getOut().setBody(new Output());
        }});
  .end();

I think we have a bug here because 'myWebService' has only 1 operation, so
the 'dispatch' step should not be necessary.




--
View this message in context: http://camel.465427.n5.nabble.com/doCatch-returns-null-tp5722851p5723008.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: doCatch returns null

Posted by "maxence.dewil" <th...@gmail.com>.
Hi,

*1. I added log statements and I enabled the tracing*

from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
  .doTry()
    .log(LoggingLevel.INFO, "entering doTry")
    .process(new Processor() { 
       @Override
        public void process(Exchange exchange) throws Exception {
           throw new IllegalStateException();
        }});
    .log(LoggingLevel.INFO, "leaving doTry")
  .doCatch(IllegalStateException.class)
    .log(LoggingLevel.INFO, "entering doCatch")
    .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getOut().setBody(new Output());
        }});
    .log(LoggingLevel.INFO, "leaving doCatch")
  .end();

Logs:
Logs.txt <http://camel.465427.n5.nabble.com/file/n5722945/Logs.txt>  
In the last trace I can see that my output is the one expected. 
Something weird is that
'business.services.transferin.OutputStartIntegrationProcessTransferIn@308a58a5'
is not surrounded by '[' and ']' like in the other traces..

*2. If I change the code to :*

from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
  .doTry()
    .log(LoggingLevel.INFO, "entering doTry")
    .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getOut().setBody(new Output());
        }});
    .log(LoggingLevel.INFO, "leaving doTry")
  .doCatch(IllegalStateException.class)
    .log(LoggingLevel.INFO, "entering doCatch")
    .log(LoggingLevel.INFO, "leaving doCatch")
  .end();

The response is empty.

*3. If I change the code to :*

from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
  .process(new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getOut().setBody(new Output());
        }});
  .doTry()
    .log(LoggingLevel.INFO, "entering doTry")
    .log(LoggingLevel.INFO, "leaving doTry")
  .doCatch(IllegalStateException.class)
    .log(LoggingLevel.INFO, "entering doCatch")
    .log(LoggingLevel.INFO, "leaving doCatch")
  .end();

Then I have my response.

Thank you for your help



--
View this message in context: http://camel.465427.n5.nabble.com/doCatch-returns-null-tp5722851p5722945.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: doCatch returns null

Posted by Charles Moulliard <ch...@gmail.com>.
Maxence,

I suggest that you try first with a simple camel CXF route

from("cxf:/myWebService?serviceClass=com.x.MyWebService")
.transform(new Output())
.log("Display output : " + new Output());

Remarks :
- What do you return from new Output ?
- CXF dataformat is by default POJO. That means that new Output should
return the objects that JAXB classes (generated by CXF plugin) will use to
send SOAP response to the HTTP client
- Transform processor allows to set the Out response used by camel exchange

Regards,

Charles


On Sun, Nov 18, 2012 at 12:41 PM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
>
> In your code there may be a bug in doCatch I am not sure. Though can
> you try adding a extra step after the process in the doCatch.
>
>
> doCatch(...)
>    .process( ...)
>    .to("log:foo")   <-- add extra step
> .end()
>
>
> Also see this FAQ about using getOut or getIn
> http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html
>
>
> On Fri, Nov 16, 2012 at 11:25 AM, maxence.dewil <th...@gmail.com>
> wrote:
> > Hi,
> >
> > tested with camel 2.10.1 and 2.10.2 :
> >
> > *When I turn the route :*
> >
> >
> from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
> > .process(new Processor() {
> >     @Override
> >     public void process(Exchange exchange) throws Exception {
> >        exchange.getOut().setBody(new Output());
> >     }});
> >
> > *into :*
> >
> >
> from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
> > .doTry()
> >     .process(new Processor() {
> >         @Override
> >         public void process(Exchange exchange) throws Exception {
> >            throw new IllegalStateException();
> >         }});
> > .doCatch(IllegalStateException.class)
> >     .process(new Processor() {
> >         @Override
> >         public void process(Exchange exchange) throws Exception {
> >             exchange.getOut().setBody(new Output());
> >         }});
> > .end();
> >
> > *Then the response body of myWebService is empty.*
> >
> > Is it possible that my route returns something in a doCatch() ?
> >
> > Any help would be appreciated
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/doCatch-returns-null-tp5722851.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
>



-- 
Charles Moulliard
Apache Committer / Sr. Enterprise Architect (RedHat)
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com

Re: doCatch returns null

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


In your code there may be a bug in doCatch I am not sure. Though can
you try adding a extra step after the process in the doCatch.


doCatch(...)
   .process( ...)
   .to("log:foo")   <-- add extra step
.end()


Also see this FAQ about using getOut or getIn
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html


On Fri, Nov 16, 2012 at 11:25 AM, maxence.dewil <th...@gmail.com> wrote:
> Hi,
>
> tested with camel 2.10.1 and 2.10.2 :
>
> *When I turn the route :*
>
> from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
> .process(new Processor() {
>     @Override
>     public void process(Exchange exchange) throws Exception {
>        exchange.getOut().setBody(new Output());
>     }});
>
> *into :*
>
> from("cxf:/myWebService?serviceClass=com.x.MyWebService").routeId("MyRoute")
> .doTry()
>     .process(new Processor() {
>         @Override
>         public void process(Exchange exchange) throws Exception {
>            throw new IllegalStateException();
>         }});
> .doCatch(IllegalStateException.class)
>     .process(new Processor() {
>         @Override
>         public void process(Exchange exchange) throws Exception {
>             exchange.getOut().setBody(new Output());
>         }});
> .end();
>
> *Then the response body of myWebService is empty.*
>
> Is it possible that my route returns something in a doCatch() ?
>
> Any help would be appreciated
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/doCatch-returns-null-tp5722851.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