You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Gvvenkat <Gv...@yahoo.com> on 2013/02/05 23:28:51 UTC

Java DSL vs Spring Dsl with Splitter and Aggregator

I am trying convert one of the JAVA DSL into Spring DSL. Java DSL reads the
file and applies the processor correctly and finally invokes the aggregator
and writes into the destination location ( also removes from the source
location as required). 

But Below equivalent (in opinion Spring DSL :) ) , does not invoke the
aggregator and never writes the destination file and does not remove the
source file so starts looping...One other important thing I should mention
is , I ambootstraping the applicationcontext xml using
org.apache.camel.spring.Main class.

Here is both JAVA DSL and Spring DSL.. Can some expert help me in
identifying the issue why Spring DSL behaviour is not the same as Java DSL.

 Spring Dsl 
 
 <camelContext xmlns="http://camel.apache.org/schema/spring">		

   <route>
        	
         from uri="file:F:/EbcConversion/Data/inbox/?
delete=true&amp;idempotent=true&amp;readLock=changed&amp;readLockCheckInterval=1500"/>
         <split streaming="true"  >
            <method bean="byteSplitterBean" method="splitBody"/>
            <process ref="decoder" />       
            <to uri="direct:start" />   			
         </split >
    </route>

       
<route>
	<from uri="direct:start" />
		<aggregate strategyRef="aggregationStrategy"
			completionTimeout="1500" completionSize="750" >
			<correlationExpression>
				<header>Exchange.FILE_NAME_ONLY</header>
			</correlationExpression>		
		<to uri="mock:aggregated"/> 
		</aggregate>
		<to
uri="file:F:/EbcConversion/Data/outbox/files/?fileExist=Append&amp;fileName=output.txt"
/>
	</route>
   
        
 </camelContext>

Java DSL 
 
from("file:F:/EbcConversion/Data/inbox?delete=true&idempotent=true&readLock=changed&readLockCheckInterval=1500").
split().method("mySplitterBean", "testBody").streaming().
process( new NewDecoder()).
aggregate(header(Exchange.FILE_NAME_ONLY), 
		new StringBodyAggregator()).completionSize(750)
		.completionTimeout(1500).
to("file:F:/EbcConversion/Data/outbox/files?fileExist=Append&fileName=output.txt");


Thanks a lot.





--
View this message in context: http://camel.465427.n5.nabble.com/Java-DSL-vs-Spring-Dsl-with-Splitter-and-Aggregator-tp5727007.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Java DSL vs Spring Dsl with Splitter and Aggregator

Posted by Willem jiang <wi...@gmail.com>.
Can you put the <to uri="direct:start"> after the </split> ?
The aggregator should be done after the split.


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





On Wednesday, February 6, 2013 at 6:28 AM, Gvvenkat wrote:

> I am trying convert one of the JAVA DSL into Spring DSL. Java DSL reads the
> file and applies the processor correctly and finally invokes the aggregator
> and writes into the destination location ( also removes from the source
> location as required).  
>  
> But Below equivalent (in opinion Spring DSL :) ) , does not invoke the
> aggregator and never writes the destination file and does not remove the
> source file so starts looping...One other important thing I should mention
> is , I ambootstraping the applicationcontext xml using
> org.apache.camel.spring.Main class.
>  
> Here is both JAVA DSL and Spring DSL.. Can some expert help me in
> identifying the issue why Spring DSL behaviour is not the same as Java DSL.
>  
> Spring Dsl  
>  
> <camelContext xmlns="http://camel.apache.org/schema/spring">  
>  
> <route>
>  
> from uri="file:F:/EbcConversion/Data/inbox/?
> delete=true&amp;idempotent=true&amp;readLock=changed&amp;readLockCheckInterval=1500"/>
> <split streaming="true" >
> <method bean="byteSplitterBean" method="splitBody"/>
> <process ref="decoder" />  
> <to uri="direct:start" />  
> </split >
> </route>
>  
> <route>
> <from uri="direct:start" />
> <aggregate strategyRef="aggregationStrategy"
> completionTimeout="1500" completionSize="750" >
> <correlationExpression>
> <header>Exchange.FILE_NAME_ONLY</header>
> </correlationExpression>  
> <to uri="mock:aggregated"/>  
> </aggregate>
> <to
> uri="file:F:/EbcConversion/Data/outbox/files/?fileExist=Append&amp;fileName=output.txt"
> />
> </route>
>  
>  
> </camelContext>
>  
> Java DSL  
>  
> from("file:F:/EbcConversion/Data/inbox?delete=true&idempotent=true&readLock=changed&readLockCheckInterval=1500").
> split().method("mySplitterBean", "testBody").streaming().
> process( new NewDecoder()).
> aggregate(header(Exchange.FILE_NAME_ONLY),  
> new StringBodyAggregator()).completionSize(750)
> .completionTimeout(1500).
> to("file:F:/EbcConversion/Data/outbox/files?fileExist=Append&fileName=output.txt");
>  
>  
> Thanks a lot.
>  
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Java-DSL-vs-Spring-Dsl-with-Splitter-and-Aggregator-tp5727007.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Java DSL vs Spring Dsl with Splitter and Aggregator

Posted by Willem jiang <wi...@gmail.com>.
Hi,

Did you have chance to check the log file to check if the camel context is started and routes are loaded rightly.

I didn't found anything is wrong by just checking the MainSpring code. Can you fill a JIRA and send a small test case on it?
So we can keep on digging the issue.


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





On Friday, February 15, 2013 at 2:27 AM, Gvvenkat wrote:

> If someone can advise, that will be great.
>  
> Thanks in advance.
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Java-DSL-vs-Spring-Dsl-with-Splitter-and-Aggregator-tp5727007p5727626.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Java DSL vs Spring Dsl with Splitter and Aggregator

Posted by Gvvenkat <Gv...@yahoo.com>.
If someone can advise, that will be great.

Thanks in advance.



--
View this message in context: http://camel.465427.n5.nabble.com/Java-DSL-vs-Spring-Dsl-with-Splitter-and-Aggregator-tp5727007p5727626.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Java DSL vs Spring Dsl with Splitter and Aggregator

Posted by Gvvenkat <Gv...@yahoo.com>.
Thanks for your continuing elp on this matter. 

I made the change of removing mock point but made no difference.. I think,
the problem could be the way it is being loaded...so I am sending you my
Main method for your kind reference...

Please let me know, if you think the root issue could be somewhere else...
Thanks


public class MainSpring { 
    private Main main; 

    public static void main(String[] args) throws Exception { 
        MainSpring example = new MainSpring(); 
        example.boot(); 
//        new ClassPathXmlApplicationContext("spring-config.xml"); 
    } 

    public void boot() throws Exception { 
        // create a Main instance 
        main = new Main(); 
        // enable hangup support so you can press ctrl + c to terminate the
JVM 
        main.enableHangupSupport(); 
       
main.setApplicationContextUri("com/barcap/camel/spring/appContext-main.xml"); 

        // run until you terminate the JVM 
        System.out.println("Starting Camel. Use ctrl + c to terminate the
JVM.\n"); 
        main.run(); 
    } 

} 




--
View this message in context: http://camel.465427.n5.nabble.com/Java-DSL-vs-Spring-Dsl-with-Splitter-and-Aggregator-tp5727007p5727294.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Java DSL vs Spring Dsl with Splitter and Aggregator

Posted by Willem jiang <wi...@gmail.com>.
Hi,

I'm not sure why you are using the mock endpoint.
Can you just change the aggregate part like this ?

<route>
<from uri="direct:start" />
<aggregate strategyRef="aggregationStrategy"
completionTimeout="1500" completionSize="750" >
<correlationExpression>
<header>Exchange.FILE_NAME_ONLY</header>
</correlationExpression>
<to
uri="file:F:/EbcConversion/Data/outbox/files/?fileExist=Append&amp;fileName=output.txt"
/>

</aggregate>
</route>


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





On Wednesday, February 6, 2013 at 11:28 AM, Gvvenkat wrote:

> Thanks William for your quick response.  
>  
> I made the change as below..but still no difference.. Please let me know, I
> did not understand your instructions correctly.
>  
> Thanks  
>  
> <camelContext>
> <route>
>  
> <from
> uri="file:F:/EbcConversion/Data/inbox/?delete=true&amp;idempotent=true&amp;readLock=changed&amp;readLockCheckInterval=1500"/>
> <split streaming="true">
> <method bean="byteSplitterBean" method="splitBody"/>
> <process ref="decoder"/>  
> </split>
> <to uri="direct:start" />  
> </route>
> <route>
> <from uri="direct:start" />
> <aggregate strategyRef="aggregationStrategy"  
> completionTimeout="1500" completionSize="750" >
> <correlationExpression>
> <header>Exchange.FILE_NAME_ONLY</header>
> </correlationExpression>  
> <to uri="mock:aggregated"/>  
> </aggregate>
> <to
> uri="file:F:/EbcConversion/Data/outbox/files/?fileExist=Append&amp;fileName=output.txt"
> />
> </route>
>  
>  
> </camelContext>
>  
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Java-DSL-vs-Spring-Dsl-with-Splitter-and-Aggregator-tp5727007p5727017.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Java DSL vs Spring Dsl with Splitter and Aggregator

Posted by Gvvenkat <Gv...@yahoo.com>.
Thanks William for your quick response. 

I made the change as below..but still no difference.. Please let me know, I
did not understand your instructions correctly.

Thanks 

<camelContext>
        <route>
        	
            <from
uri="file:F:/EbcConversion/Data/inbox/?delete=true&amp;idempotent=true&amp;readLock=changed&amp;readLockCheckInterval=1500"/>
            <split streaming="true">
                <method bean="byteSplitterBean" method="splitBody"/>
                <process ref="decoder"/>		                    	
             </split>
             <to uri="direct:start" />  
        </route>
<route>
        <from uri="direct:start" />
                <aggregate strategyRef="aggregationStrategy" 
                        completionTimeout="1500" completionSize="750" >
                        <correlationExpression>
                                <header>Exchange.FILE_NAME_ONLY</header>
                        </correlationExpression>                
                <to uri="mock:aggregated"/>  
                </aggregate>
                <to
uri="file:F:/EbcConversion/Data/outbox/files/?fileExist=Append&amp;fileName=output.txt"
/>
        </route>
    
        
 </camelContext>





--
View this message in context: http://camel.465427.n5.nabble.com/Java-DSL-vs-Spring-Dsl-with-Splitter-and-Aggregator-tp5727007p5727017.html
Sent from the Camel - Users mailing list archive at Nabble.com.