You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2009/11/05 06:03:13 UTC
Re: svn commit: r832981 - /camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
Hi
There is some code in Camel uitl to set the init cause when throwing
an IOException so it has the correct stacktrace.
What you do is just adding one giant big message.
It should be something like this
IOException cause = new IOException("xxxx"):
cause.initCause(e);
throw cause;
On Thu, Nov 5, 2009 at 4:17 AM, <ni...@apache.org> wrote:
> Author: ningjiang
> Date: Thu Nov 5 03:17:43 2009
> New Revision: 832981
>
> URL: http://svn.apache.org/viewvc?rev=832981&view=rev
> Log:
> CAMEL-2129 throw the exception of camel ProduceTemplate in CamelConduit
>
> Modified:
> camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
>
> Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java?rev=832981&r1=832980&r2=832981&view=diff
> ==============================================================================
> --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java (original)
> +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java Thu Nov 5 03:17:43 2009
> @@ -17,12 +17,14 @@
> package org.apache.camel.component.cxf.transport;
>
> import java.io.IOException;
> +import java.io.InputStream;
> import java.io.OutputStream;
> import java.util.logging.Level;
> import java.util.logging.Logger;
>
> import org.apache.camel.CamelContext;
> import org.apache.camel.ExchangePattern;
> +import org.apache.camel.InvalidPayloadException;
> import org.apache.camel.Processor;
> import org.apache.camel.ProducerTemplate;
> import org.apache.camel.component.cxf.CxfConstants;
> @@ -158,7 +160,7 @@
> }
>
>
> - private void commitOutputMessage() {
> + private void commitOutputMessage() throws IOException {
> ExchangePattern pattern;
> if (isOneWay) {
> pattern = ExchangePattern.InOnly;
> @@ -179,15 +181,25 @@
> }
> });
> exchange.setProperty(CxfConstants.CXF_EXCHANGE, outMessage.getExchange());
> + // Throw the exception that the template get
> + if (exchange.getException() != null) {
> + throw new IOException("Can't get the response message. Caused by " + exchange.getException());
> + }
> if (!isOneWay) {
> handleResponse(exchange);
> }
>
> }
>
> - private void handleResponse(org.apache.camel.Exchange exchange) {
> - org.apache.cxf.message.Message inMessage = CxfSoapBinding.getCxfInMessage(headerFilterStrategy,
> + private void handleResponse(org.apache.camel.Exchange exchange) throws IOException {
> + org.apache.cxf.message.Message inMessage = null;
> + try {
> + inMessage = CxfSoapBinding.getCxfInMessage(headerFilterStrategy,
> exchange, true);
> + } catch (Exception ex) {
> + // Throw IOException here
> + throw new IOException("Can't get the response message. Caused by: " + ex);
> + }
> incomingObserver.onMessage(inMessage);
> }
> }
>
>
>
--
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
Re: svn commit: r832981 - /camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
Posted by Willem Jiang <wi...@gmail.com>.
Hi Claus,
I was trying to use new IOException("xxx", ex), but it is new to JDK
1.6. So thanks for point that out, I will update the code to using the
util method in the IOHelper.
Cheers,
Willem
Claus Ibsen wrote:
> Hi
>
> There is some code in Camel uitl to set the init cause when throwing
> an IOException so it has the correct stacktrace.
> What you do is just adding one giant big message.
>
> It should be something like this
>
> IOException cause = new IOException("xxxx"):
> cause.initCause(e);
> throw cause;
>
>
>
> On Thu, Nov 5, 2009 at 4:17 AM, <ni...@apache.org> wrote:
>> Author: ningjiang
>> Date: Thu Nov 5 03:17:43 2009
>> New Revision: 832981
>>
>> URL: http://svn.apache.org/viewvc?rev=832981&view=rev
>> Log:
>> CAMEL-2129 throw the exception of camel ProduceTemplate in CamelConduit
>>
>> Modified:
>> camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
>>
>> Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
>> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java?rev=832981&r1=832980&r2=832981&view=diff
>> ==============================================================================
>> --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java (original)
>> +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java Thu Nov 5 03:17:43 2009
>> @@ -17,12 +17,14 @@
>> package org.apache.camel.component.cxf.transport;
>>
>> import java.io.IOException;
>> +import java.io.InputStream;
>> import java.io.OutputStream;
>> import java.util.logging.Level;
>> import java.util.logging.Logger;
>>
>> import org.apache.camel.CamelContext;
>> import org.apache.camel.ExchangePattern;
>> +import org.apache.camel.InvalidPayloadException;
>> import org.apache.camel.Processor;
>> import org.apache.camel.ProducerTemplate;
>> import org.apache.camel.component.cxf.CxfConstants;
>> @@ -158,7 +160,7 @@
>> }
>>
>>
>> - private void commitOutputMessage() {
>> + private void commitOutputMessage() throws IOException {
>> ExchangePattern pattern;
>> if (isOneWay) {
>> pattern = ExchangePattern.InOnly;
>> @@ -179,15 +181,25 @@
>> }
>> });
>> exchange.setProperty(CxfConstants.CXF_EXCHANGE, outMessage.getExchange());
>> + // Throw the exception that the template get
>> + if (exchange.getException() != null) {
>> + throw new IOException("Can't get the response message. Caused by " + exchange.getException());
>> + }
>> if (!isOneWay) {
>> handleResponse(exchange);
>> }
>>
>> }
>>
>> - private void handleResponse(org.apache.camel.Exchange exchange) {
>> - org.apache.cxf.message.Message inMessage = CxfSoapBinding.getCxfInMessage(headerFilterStrategy,
>> + private void handleResponse(org.apache.camel.Exchange exchange) throws IOException {
>> + org.apache.cxf.message.Message inMessage = null;
>> + try {
>> + inMessage = CxfSoapBinding.getCxfInMessage(headerFilterStrategy,
>> exchange, true);
>> + } catch (Exception ex) {
>> + // Throw IOException here
>> + throw new IOException("Can't get the response message. Caused by: " + ex);
>> + }
>> incomingObserver.onMessage(inMessage);
>> }
>> }
>>
>>
>>
>
>
>