On Mon, Dec 29, 2008 at 12:03 PM, Ganesh_Progress <[email protected]> wrote:
>
>
>
> Claus Ibsen-2 wrote:
>>
>> On Mon, Dec 29, 2008 at 11:08 AM, Ganesh_Progress <[email protected]>
>> wrote:
>>>
>>> Hi,
>>>
>>> I am new to the Camel world and am trying to learn the behavior of the
>>> aggregator pattern.
>>>
>>> I have created a camel configuration with aggregator pattern with file
>>> endpoints.
>>>
>>> I got the following consistent error when I tried to run the created the
>>> configuration. java.io.FileNotFoundException.
>>>
>>> Exception:
>>> Caused by: java.io.FileNotFoundException:
>>> D:\FuseEclipse3.4.1\runtime-New_configuration(2)\Fuse\Aggregator\out\Copy
>>> of
>>> Sample.xml (The system cannot find the file specified)
>>>
>>>      at java.io.FileInputStream.open(Native Method)
>>>
>>>      at java.io.FileInputStream.<init>(Unknown Source)
>>>
>>>      at java.io.FileInputStream.<init>(Unknown Source)
>>>
>>>      at sun.net.www.protocol.file.FileURLConnection.connect(Unknown
>>> Source)
>>>
>>>      at
>>> sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown
>>> Source)
>>>
>>>      at
>>> com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown
>>> Source)
>>>
>>>      at
>>> com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown
>>> Source)
>>>
>>>      at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
>>> Source)
>>>
>>>      at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
>>> Source)
>>>
>>>      at
>>> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
>>> Source)
>>>
>>>      at
>>> com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown
>>> Source)
>>>
>>>      at
>>> com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
>>> Source)
>>>
>>>      at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
>>>
>>>      at
>>> org.apache.camel.converter.jaxp.XmlConverter.toDOMDocument(XmlConverter.java:528)
>>>
>>>      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>
>>>      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>
>>>      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>
>>>      at java.lang.reflect.Method.invoke(Unknown Source)
>>>
>>>      at
>>> org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:434)
>>>
>>>      ... 12 more
>>>
>>>
>>> Following is the Camel Configuration, for which I got the "file not found
>>> exception".
>>>
>>> <beans xmlns="http://www.springframework.org/schema/beans";
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>> xsi:schemaLocation="
>>> http://www.springframework.org/schema/beans
>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>>> http://activemq.apache.org/camel/schema/spring
>>> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd";><camelContext
>>> id="camelroute" xmlns="http://activemq.apache.org/camel/schema/spring";>
>>> <route xmlns="http://activemq.apache.org/camel/schema/spring";>
>>>    <from
>>> uri="file:///D:/FID_341/runtime-New_configuration/FuseFIDCamel/Aggregator/in"
>>> id="Camel_File_2"/>
>>>    <aggregator batchTimeout="3000" batchSize="2" id="Camel_Aggregator_4">
>>>        <xpath>/Persons/Person/Name</xpath>
>>>        <to
>>> uri="file:///D:/FID_341/runtime-New_configuration/FuseFIDCamel/Aggregator/out"
>>> id="Camel_File_6"/>
>>>    </aggregator>
>>> </route>
>>> </camelContext></beans>
>>>
>>>
>>> Finally I could find the workaround to overcome the issue. I could made
>>> it
>>> successfully running by modifying the From URI by adding the "?noop=true"
>>> at
>>> the end.
>>>
>>> Below is the camel configuration, which I run successfully.
>>>
>>> <beans xmlns="http://www.springframework.org/schema/beans";
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>> xsi:schemaLocation="
>>> http://www.springframework.org/schema/beans
>>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>>> http://activemq.apache.org/camel/schema/spring
>>> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd";><camelContext
>>> id="camelroute" xmlns="http://activemq.apache.org/camel/schema/spring";>
>>> <route xmlns="http://activemq.apache.org/camel/schema/spring";>
>>>    <from
>>> uri="file:///D:/FID_341/runtime-New_configuration/FuseFIDCamel/Aggregator/in?noop=true"
>>> id="Camel_File_2"/>
>>>    <aggregator batchTimeout="3000" batchSize="2" id="Camel_Aggregator_4">
>>>        <xpath>/Persons/Person/Name</xpath>
>>>        <to
>>> uri="file:///D:/FID_341/runtime-New_configuration/FuseFIDCamel/Aggregator/out"
>>> id="Camel_File_6"/>
>>>    </aggregator>
>>> </route>
>>> </camelContext></beans>
>>>
>>>
>>> With the above exercise, I understand that File endpoint component is
>>> consuming the message from file and then it is moving the file to other
>>> location. But Aggregator is trying to pick the file from the previous
>>> location.
>>>
>>> Can somebody validate the above statement? I feel this will be a bug and
>>> File endpoint should be able to pass the message exchange to the
>>> Aggregator
>>> and Aggregator should process the same message exchange. Can somebody
>>> confirm that this is an issue?
>> Ah the route is like two fold when using the aggregator as it's
>> batching the file exchanges. By default the file consumer will move
>> processed file into a .camel subfolder.
>> Appending ?noop=true hinders this and thus the file remains untouched.
>>
>> What you need to do is to ensure the exchange is not file based,
>> anymore. You can do this by converting the payload from java.io.File
>> to eg. String or byte[] etc.
>>
>> So inserting a convertBodyTo so do the trick
>>
>>     <from
>>
>> uri="file:///D:/FID_341/runtime-New_configuration/FuseFIDCamel/Aggregator/in"
>>  id="Camel_File_2"/>
>>     <convertBodyTo type="java.lang.String"/>
>>     <aggregator batchTimeout="3000" batchSize="2" id="Camel_Aggregator_4">
>>
>> Could you post back if that works. Then I guess we should improve the
>> wiki documentation with your example: file -> aggregate with this
>> pitfall
>>
>>>
>>> Regards
>>> Ganesh
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/java.io.FileNotFoundException%2C-when-tries-to-run-the-aggregator-pattern-tp21201076s22882p21201076.html
>>> Sent from the Camel - Development mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> Hi Claus Ibsen,
>
> By inserting a convertBodyTo doesn't work. Got the same error.
Ahh there was a flaw in the batch processor that just recently has
been fixed in 1.5.1 or later. So we must use a workaround with
intermediate seda queues

So your route should be split into two combined with seda queues such as:

from -> convert body to -> to("seda:foo")
from("seda:foo") -> aggegate



>
> -Regards
> Ganesh
> --
> View this message in context: 
> http://www.nabble.com/java.io.FileNotFoundException%2C-when-tries-to-run-the-aggregator-pattern-tp21201076s22882p21201683.html
> Sent from the Camel - Development mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Reply via email to