You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "lakshmi.prashant" <la...@gmail.com> on 2015/04/20 11:35:28 UTC

Re: Data Corruption in SFTP in Parallel Multicast branches

Hi,

  We have another example of data corruption with Parallel Multicast. This
issue is there even in camel-core 2.14.2.

  If we change to serial multicast, the issue disappears. 

  I have a route with a camel producer (to uri) that writes data in the
exchange & this data is of type stream cache & it sets a huge data in the
exchange body.

  Immediately afterward, if I have a parallel multicast and in each
multicast branch, if I have some XPath based content filter, I get either of
the below exceptions:

*  Error               =
org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
/queryCompoundEmployeeResponse/CompoundEmployee. Reason:
javax.xml.xpath.XPathExpressionException: Failure converting a node of class
javax.xml.transform.sax.SAXSource: I/O error reported by XML parser
processing null: Invalid byte 2 of 2-byte UTF-8 sequence., cause:
javax.xml.xpath.XPathExpressionException: Failure converting a node of class
javax.xml.transform.sax.SAXSource: I/O error reported by XML parser
processing null: Invalid byte 2 of 2-byte UTF-8 sequence.
*

(or) 

*
org.apache.camel.CamelExchangeException: Parallel processing failed for
number 0. Exchange[Message: [Body is not logged]]. Caused by:
[org.apache.camel.TypeConversionException - Error during type conversion
from type: java.lang.String to the required type: org.w3c.dom.Document with
value [Body is not logged] due org.xml.sax.SAXParseException; lineNumber: 1;
columnNumber: 1; Content is not allowed in prolog.]]|
*


I have even tried to set the Exchange.CHARSET_NAME property in the exchange,
but that does not help.

My beans.xml looks like the below:


<camel:route>
<camel:from
uri="quartz2://test.parallel.multicast.errorTimerEventDefinition11?fireNow=true&amp;trigger.repeatCount=0&amp;trigger.repeatInterval=0"/>

<camel:setProperty propertyName="Exchange.CHARSET_NAME">
	<camel:constant>UTF-8</camel:constant>
</camel:setProperty>

<camel:to  uri="myProducer"/> 
	
	
<camel:multicast id="ParallelGateway_1" parallelProcessing="true"
stopOnException="true">
	<camel:to uri="direct://SequenceFlow_5"/>
	<camel:to uri="direct://SequenceFlow_7"/>
</camel:multicast>
</camel:route>

<camel:route>
	<camel:from uri="direct://SequenceFlow_5"/>
	
	<camel:setBody id="CallActivity_4_1429516652727">
		<camel:xpath
resultType="org.w3c.dom.NodeList">//CompoundEmployee</camel:xpath>
	</camel:setBody>
	<camel:setBody id="CallActivity_5_1429516652731">
	
<camel:simple>&lt;CompoundResponse&gt;${in.body}&lt;/CompoundResponse&gt;</camel:simple>
	</camel:setBody>
	<camel:to id="MessageFlow_2_1429516652733"
uri="sap-util:preventPathTraversal"/>
	<camel:to ref="Receiver1_"/>
	
</camel:route>


<camel:route>
	<camel:from uri="direct://SequenceFlow_7"/>
	<camel:setBody id="CallActivity_7_1429516652738">
		<camel:xpath 
resultType="org.w3c.dom.NodeList">/queryCompoundEmployeeResponse/CompoundEmployee</camel:xpath>
	</camel:setBody>
	<camel:setBody id="CallActivity_1_1429516652742">
	
<camel:simple>&lt;CompoundResponse&gt;${in.body}&lt;/CompoundResponse&gt;</camel:simple>
	</camel:setBody>
	<camel:to id="MessageFlow_1_1429516652744"
uri="sap-util:preventPathTraversal"/>
	<camel:to ref="Receiver2_"/>	
	
</camel:route>


It looks like both the branches are still reading from the same stream and
that causes some race condition happens.
The error states that the XML parser for XPath extraction in 1 branch is
finding unwanted characters at the start of the data in the body of the
(branch) exchange, due to the above.

Debug Trace:

at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)
	at
org.apache.camel.processor.MulticastProcessor.doProcessParallel(MulticastProcessor.java:736)
	at
org.apache.camel.processor.MulticastProcessor.access$200(MulticastProcessor.java:83)
	at
org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:304)
	at
org.apache.camel.processor.MulticastProcessor$1.call(MulticastProcessor.java:289)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:812)
Caused by: org.apache.camel.RuntimeCamelException:
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException:
Invalid byte 1 of 1-byte UTF-8 sequence.
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1364)
	at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1006)
	at
org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:276)
	at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:114)
	... 35 common frames omitted
Caused by:
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException:
Invalid byte 1 of 1-byte UTF-8 sequence.
	at
com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:687)
	at
com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:557)
	at
com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1802)
	at
com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(XMLEntityScanner.java:1670)
	at
com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(XMLEntityScanner.java:1708)
	at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1748)
	at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
	at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
	at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
	at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
	at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:857)
	at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
	at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
	at
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
	at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:128)
	at
org.apache.camel.converter.jaxp.XmlConverter.toDOMDocument(XmlConverter.java:860)


Can you kindly help with any possible solution (or) is this a bug with camel
parallel multicasr?

Thanks,
Lakshmi




--
View this message in context: http://camel.465427.n5.nabble.com/Data-Corruption-in-SFTP-in-Parallel-Multicast-branches-tp5761673p5766056.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Data Corruption in SFTP in Parallel Multicast branches

Posted by Franz Paul Forsthofer <em...@googlemail.com>.
Hello Lakshmi,

it could be that this issue is related to
https://issues.apache.org/jira/browse/CAMEL-8688

There we have made a patch in the current snapshot (version 2.16)

Can you try to reproduce your problem on the current snapshot?

Regards Franz

On Tue, May 12, 2015 at 11:39 AM, lakshmi.prashant
<la...@gmail.com> wrote:
> Hi,
>
>  If direct is changed to SEDA, the multiple branches still fail.
>
> /Error processing exchange. Exchange[Message: [Body is instance of
> org.apache.camel.StreamCache]]. Caused by: [org.quartz.JobExecutionException
> - org.apache.camel.CamelExchangeException: Parallel processing failed for
> number 0. Exchange[Message: [Body is instance of
> org.apache.camel.StreamCache]].
>
>  Caused by: [org.apache.camel.builder.xml.InvalidXPathExpression - Invalid
> xpath: /queryCompoundEmployeeResponse/CompoundEmployee.
> Reason: javax.xml.xpath.XPathExpressionException: Failure converting a node
> of class javax.xml.transform.sax.SAXSource: I/O error reported by XML parser
> processing null: Invalid byte 2 of 4-byte UTF-8 sequence.]]|/
>
>
>  If I convert the streamcache to String / byte[] after the stream cache
> producer & before the multicast, the issue does not arise.
>
>
> <camel:to  uri="myProducer"/>         *
> <camel:convertBodyTo type="java.lang.String" charset="UTF-8" />  *
> <camel:multicast id="ParallelGateway_1" parallelProcessing="true"
> stopOnException="true">
>         <camel:to uri="direct://SequenceFlow_5"/>
>         <camel:to uri="direct://SequenceFlow_7"/>
> </camel:multicast>
> </camel:route>
>
> Thanks,
> Lakshmi
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Data-Corruption-in-SFTP-in-Parallel-Multicast-branches-tp5761673p5767007.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Data Corruption in SFTP in Parallel Multicast branches

Posted by "lakshmi.prashant" <la...@gmail.com>.
Hi,

 If direct is changed to SEDA, the multiple branches still fail. 

/Error processing exchange. Exchange[Message: [Body is instance of
org.apache.camel.StreamCache]]. Caused by: [org.quartz.JobExecutionException
- org.apache.camel.CamelExchangeException: Parallel processing failed for
number 0. Exchange[Message: [Body is instance of
org.apache.camel.StreamCache]].

 Caused by: [org.apache.camel.builder.xml.InvalidXPathExpression - Invalid
xpath: /queryCompoundEmployeeResponse/CompoundEmployee. 
Reason: javax.xml.xpath.XPathExpressionException: Failure converting a node
of class javax.xml.transform.sax.SAXSource: I/O error reported by XML parser
processing null: Invalid byte 2 of 4-byte UTF-8 sequence.]]|/


 If I convert the streamcache to String / byte[] after the stream cache
producer & before the multicast, the issue does not arise.


<camel:to  uri="myProducer"/>         *
<camel:convertBodyTo type="java.lang.String" charset="UTF-8" />  *   
<camel:multicast id="ParallelGateway_1" parallelProcessing="true"
stopOnException="true">
        <camel:to uri="direct://SequenceFlow_5"/>
        <camel:to uri="direct://SequenceFlow_7"/>
</camel:multicast>
</camel:route>

Thanks,
Lakshmi



--
View this message in context: http://camel.465427.n5.nabble.com/Data-Corruption-in-SFTP-in-Parallel-Multicast-branches-tp5761673p5767007.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Data Corruption in SFTP in Parallel Multicast branches

Posted by contactreji <co...@gmail.com>.
Hi

Have u tried replacing
<camel:multicast id="ParallelGateway_1" parallelProcessing="true"
stopOnException="true">
        <camel:to uri="direct://SequenceFlow_5"/>
        <camel:to uri="direct://SequenceFlow_7"/>
</camel:multicast>


With

<camel:multicast id="ParallelGateway_1" parallelProcessing="true"
stopOnException="true">
        <camel:inOnly uri="seda:SequenceFlow_5"/>
        <camel:inOnly uri="seda:SequenceFlow_7"/>
</camel:multicast>

Reji



-----
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
--
View this message in context: http://camel.465427.n5.nabble.com/Data-Corruption-in-SFTP-in-Parallel-Multicast-branches-tp5761673p5766120.html
Sent from the Camel - Users mailing list archive at Nabble.com.