You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Willem jiang <wi...@gmail.com> on 2012/11/21 16:04:23 UTC

Re: svn commit: r1412100 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/DefaultCxfBinding.javatest/java/org/apache/camel/component/cxf/CxfConsumerWithTryCatchTest.java

Hi Claus,

Thanks for pointing that out, I was thinking the log could help user to find out why the response message is null, but I didn't realize that will make DEBUG level too verbose.
As the DefaultCxfBinding is using trace for those message,  I will change the log to be trace in my next commit.

-- 
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.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Wednesday, November 21, 2012 at 10:28 PM, Claus Ibsen wrote:

> Hi Willem
> 
> I suggest to use TRACE logging for those log messages you added. As a
> DEBUG logging they don't bring much value for end users. Its really
> only needed when tracing some weird issue.
> 
> The logging at DEBUG level shouldn't be too verbose.
> 
> 
> 
> On Wed, Nov 21, 2012 at 2:54 PM, <ningjiang@apache.org (mailto:ningjiang@apache.org)> wrote:
> > Author: ningjiang
> > Date: Wed Nov 21 13:54:02 2012
> > New Revision: 1412100
> > 
> > URL: http://svn.apache.org/viewvc?rev=1412100&view=rev
> > Log:
> > CAMEL-5810 Fixed the issue of CXF + Code first + No recipient list + doCatch = route returns null
> > 
> > Added:
> > camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerWithTryCatchTest.java
> > Modified:
> > camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
> > 
> > Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
> > URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java?rev=1412100&r1=1412099&r2=1412100&view=diff
> > ==============================================================================
> > --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java (original)
> > +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java Wed Nov 21 13:54:02 2012
> > @@ -282,9 +282,16 @@ public class DefaultCxfBinding implement
> > 
> > org.apache.camel.Message response;
> > if (camelExchange.getPattern().isOutCapable()) {
> > - response = camelExchange.getOut();
> > + if (camelExchange.hasOut()) {
> > + response = camelExchange.getOut();
> > + LOG.debug("Get the response from the out message");
> > + } else { // Take the in message as a fall back
> > + response = camelExchange.getIn();
> > + LOG.debug("Get the response from the in message as a fallback");
> > + }
> > } else {
> > response = camelExchange.getIn();
> > + LOG.debug("Get the response from the in message");
> > }
> > 
> > // propagate response context
> > 
> > Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerWithTryCatchTest.java
> > URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerWithTryCatchTest.java?rev=1412100&view=auto
> > ==============================================================================
> > --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerWithTryCatchTest.java (added)
> > +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerWithTryCatchTest.java Wed Nov 21 13:54:02 2012
> > @@ -0,0 +1,94 @@
> > +/**
> > + * Licensed to the Apache Software Foundation (ASF) under one or more
> > + * contributor license agreements. See the NOTICE file distributed with
> > + * this work for additional information regarding copyright ownership.
> > + * The ASF licenses this file to You under the Apache License, Version 2.0
> > + * (the "License"); you may not use this file except in compliance with
> > + * the License. You may obtain a copy of the License at
> > + *
> > + * http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +
> > +package org.apache.camel.component.cxf;
> > +
> > +import java.util.HashMap;
> > +import java.util.List;
> > +import java.util.Map;
> > +
> > +import javax.servlet.ServletRequest;
> > +
> > +import org.apache.camel.Exchange;
> > +import org.apache.camel.Message;
> > +import org.apache.camel.Processor;
> > +import org.apache.camel.builder.RouteBuilder;
> > +import org.apache.camel.component.cxf.common.message.CxfConstants;
> > +import org.apache.camel.test.junit4.CamelTestSupport;
> > +import org.apache.cxf.BusFactory;
> > +import org.apache.cxf.endpoint.Client;
> > +import org.apache.cxf.frontend.ClientFactoryBean;
> > +import org.apache.cxf.frontend.ClientProxyFactoryBean;
> > +import org.junit.Test;
> > +
> > +
> > +public class CxfConsumerWithTryCatchTest extends CxfConsumerTest {
> > +
> > + private static final String ECHO_OPERATION = "echo";
> > + private static final String ECHO_BOOLEAN_OPERATION = "echoBoolean";
> > +
> > + @Override
> > + public boolean isCreateCamelContextPerClass() {
> > + return true;
> > + }
> > +
> > + // START SNIPPET: example
> > + protected RouteBuilder createRouteBuilder() {
> > + return new RouteBuilder() {
> > + public void configure() {
> > + from(SIMPLE_ENDPOINT_URI).choice().when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_OPERATION)).process(new Processor() {
> > + public void process(final Exchange exchange) {
> > + Message in = exchange.getIn();
> > + // Get the parameter list
> > + List<?> parameter = in.getBody(List.class);
> > + // Get the operation name
> > + String operation = (String)in.getHeader(CxfConstants.OPERATION_NAME);
> > + Object result = operation + " " + (String)parameter.get(0);
> > + // Put the result back
> > + exchange.getOut().setBody(result);
> > + }
> > + })
> > + .when(header(CxfConstants.OPERATION_NAME).isEqualTo(ECHO_BOOLEAN_OPERATION))
> > + .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 {
> > + Message in = exchange.getIn();
> > + // Get the parameter list
> > + List<?> parameter = in.getBody(List.class);
> > + // Put the result back
> > + exchange.getOut().setBody(parameter.get(0));
> > + }
> > + })
> > + .end();
> > + }
> > + };
> > + }
> > +
> > + @Test
> > + public void testXmlDeclaration() throws Exception {
> > + // do nothing here
> > + }
> > +
> > +
> > +}
> 
> 
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com (mailto:cibsen@redhat.com)
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen