You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ebinsingh <eb...@VerizonWireless.com> on 2011/11/08 19:13:46 UTC

correlationExpression while Aggregating

Hi All,

Appreciate your help.

I have a bean that returns a String or a StringBuilder. I want to aggregate
the first 2000 String's returned by this method into a single file.

I am having trouble with finding the right correlationExpression to
aggregate them.

Please can you help me fix this.

Thanks & regards,
Ebe

--
View this message in context: http://camel.465427.n5.nabble.com/correlationExpression-while-Aggregating-tp4975191p4975191.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: correlationExpression while Aggregating

Posted by Claus Ibsen <cl...@gmail.com>.
Whats the code in the MyAggregationStrategy ?
Make sure you do this correctly, when setting the data on the exchange
in this strategy.




On Tue, Nov 8, 2011 at 8:17 PM, ebinsingh
<eb...@verizonwireless.com> wrote:
> Thanks a lot.
>
> Below is the code am using and I get this error message. Not sure what is
> missing.
>
>                from("file:C:\\camelProject\\data\\inbox\\")
>                .log("Starting to process big file: ${header.CamelFileName}")
>                .split(body().tokenize("\n")).streaming()
>                .unmarshal(csv).convertBodyTo(List.class)
>                .bean(Parser1.class,"create_fp_record1")
>                .aggregate(constant(true),  new
> MyAggregationStrategy()).completionSize(2000)
>
> .to("file:C:\\camelProject\\data\\outbox\\?fileExist=Append&fileName=${file:onlyname.noext}");
>
>
>        public String create_fp_record1(List<String> marsRecord) {
>                log.debug("START to parse record: ");
>                StringBuilder str = new StringBuilder(300);
>                str.append("L2|");
>                str.append(marsRecord.get(1));
>                str.append(delimeter);
> .
> .
> .
> .
> .
>                str.append(delimeter);
>                str.append("xx");
>                log.debug("END parse record");
>                return str;
>
>
> I see these logs as well as the Error log below. Not sure how these become
> null.
>
> 2011-11-08 13:42:35,827 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] bean.BeanProcessor - Setting bean
> invocation result on the IN message: L2|204043110533530
>
> 2011-11-08 13:42:35,827 INFO  [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
> - Found 3 packages with 15 @Converter classes to load
> 2011-11-08 13:42:35,827 INFO  [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.DefaultTypeConverter - Loaded
> 154 core type converters (total 154 type converters)
> 2011-11-08 13:42:35,827 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.DefaultTypeConverter - Loading
> additional type converters ...
> 2011-11-08 13:42:35,827 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
> - Loading file META-INF/services/org/apache/camel/TypeConverter to retrieve
> list of packages, from url:
> jar:file:/C:/Exec/apache-camel/lib/camel-spring-ws-2.8.1.jar!/META-INF/services/org/apache/camel/TypeConverter
> 2011-11-08 13:42:35,827 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
> - Loading file META-INF/services/org/apache/camel/TypeConverter to retrieve
> list of packages, from url:
> jar:file:/C:/Exec/apache-camel/lib/camel-spring-integration-2.8.1.jar!/META-INF/services/org/apache/camel/TypeConverter
> 2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
> - Loading file META-INF/services/org/apache/camel/TypeConverter to retrieve
> list of packages, from url:
> jar:file:/C:/Exec/apache-camel/lib/camel-core-2.8.1.jar!/META-INF/services/org/apache/camel/TypeConverter
> 2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
> - Loading file META-INF/services/org/apache/camel/TypeConverter to retrieve
> list of packages, from url:
> file:/C:/MyWorkspaces/camelTest/src/resources/META-INF/services/org/apache/camel/TypeConverter
> 2011-11-08 13:42:35,842 INFO  [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
> - Loaded 2 @Converter classes
> 2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] impl.DefaultPackageScanClassResolver -
> Searching for annotations of org.apache.camel.Converter in packages:
> [com.verizon.learn.camel.utils]
> 2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] impl.DefaultPackageScanClassResolver -
> Found: [class com.verizon.learn.camel.utils.NamesConverter]
> 2011-11-08 13:42:35,842 INFO  [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
> - Found 1 packages with 1 @Converter classes to load
> 2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.DefaultTypeConverter - Loading
> additional type converters done
> 2011-11-08 13:42:35,842 INFO  [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] converter.DefaultTypeConverter - Loaded
> additional 6 type converters (total 160 type converters) in 0.015 seconds
> 2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
> file://C:camelProjectdatainboxmars] aggregate.AggregateProcessor -
> Aggregation complete for correlation key true sending aggregated exchange:
> Exchange[Message: null
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/correlationExpression-while-Aggregating-tp4975191p4975364.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: correlationExpression while Aggregating

Posted by ebinsingh <eb...@VerizonWireless.com>.
Thanks a lot.

Below is the code am using and I get this error message. Not sure what is
missing.

		from("file:C:\\camelProject\\data\\inbox\\")
		.log("Starting to process big file: ${header.CamelFileName}")
		.split(body().tokenize("\n")).streaming()
		.unmarshal(csv).convertBodyTo(List.class)
		.bean(Parser1.class,"create_fp_record1")
		.aggregate(constant(true),  new
MyAggregationStrategy()).completionSize(2000)
	
.to("file:C:\\camelProject\\data\\outbox\\?fileExist=Append&fileName=${file:onlyname.noext}");


	public String create_fp_record1(List<String> marsRecord) {
		log.debug("START to parse record: ");
		StringBuilder str = new StringBuilder(300);
		str.append("L2|");
		str.append(marsRecord.get(1));
		str.append(delimeter);
.
.
.
.
.
		str.append(delimeter);
		str.append("xx");
		log.debug("END parse record");		
		return str;


I see these logs as well as the Error log below. Not sure how these become
null.

2011-11-08 13:42:35,827 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] bean.BeanProcessor - Setting bean
invocation result on the IN message: L2|204043110533530

2011-11-08 13:42:35,827 INFO  [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
- Found 3 packages with 15 @Converter classes to load
2011-11-08 13:42:35,827 INFO  [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.DefaultTypeConverter - Loaded
154 core type converters (total 154 type converters)
2011-11-08 13:42:35,827 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.DefaultTypeConverter - Loading
additional type converters ...
2011-11-08 13:42:35,827 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
- Loading file META-INF/services/org/apache/camel/TypeConverter to retrieve
list of packages, from url:
jar:file:/C:/Exec/apache-camel/lib/camel-spring-ws-2.8.1.jar!/META-INF/services/org/apache/camel/TypeConverter
2011-11-08 13:42:35,827 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
- Loading file META-INF/services/org/apache/camel/TypeConverter to retrieve
list of packages, from url:
jar:file:/C:/Exec/apache-camel/lib/camel-spring-integration-2.8.1.jar!/META-INF/services/org/apache/camel/TypeConverter
2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
- Loading file META-INF/services/org/apache/camel/TypeConverter to retrieve
list of packages, from url:
jar:file:/C:/Exec/apache-camel/lib/camel-core-2.8.1.jar!/META-INF/services/org/apache/camel/TypeConverter
2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
- Loading file META-INF/services/org/apache/camel/TypeConverter to retrieve
list of packages, from url:
file:/C:/MyWorkspaces/camelTest/src/resources/META-INF/services/org/apache/camel/TypeConverter
2011-11-08 13:42:35,842 INFO  [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
- Loaded 2 @Converter classes
2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] impl.DefaultPackageScanClassResolver -
Searching for annotations of org.apache.camel.Converter in packages:
[com.verizon.learn.camel.utils]
2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] impl.DefaultPackageScanClassResolver -
Found: [class com.verizon.learn.camel.utils.NamesConverter]
2011-11-08 13:42:35,842 INFO  [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.AnnotationTypeConverterLoader
- Found 1 packages with 1 @Converter classes to load
2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.DefaultTypeConverter - Loading
additional type converters done
2011-11-08 13:42:35,842 INFO  [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] converter.DefaultTypeConverter - Loaded
additional 6 type converters (total 160 type converters) in 0.015 seconds
2011-11-08 13:42:35,842 DEBUG [Camel (camel-1) thread #0 -
file://C:camelProjectdatainboxmars] aggregate.AggregateProcessor -
Aggregation complete for correlation key true sending aggregated exchange:
Exchange[Message: null

--
View this message in context: http://camel.465427.n5.nabble.com/correlationExpression-while-Aggregating-tp4975191p4975364.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: correlationExpression while Aggregating

Posted by boday <be...@initekconsulting.com>.
Ebe, what does your bean return?  If its just a String, then just use the
completionSize() like this...

from("direct:start")
.to("bean:myBean")
.aggregate(constant(true), new MyAggregationStrategy()).completionSize(2000)
.to("file:myFile");

If the bean returns a List of Strings, then you can split them, then
aggregate them based on your strategy

from("direct:start")
.to("bean:myBean")  //returns List<String>
.split(body())  //splits into String
.aggregate(constant(true), new MyAggregationStrategy()).completionSize(2000)   
.to("file:myFile");

see this page, http://camel.apache.org/aggregator2.html for more details...


ebinsingh wrote:
> 
> Hi All,
> 
> Appreciate your help.
> 
> I have a bean that returns a String or a StringBuilder. I want to
> aggregate the first 2000 String's returned by this method into a single
> file.
> 
> I am having trouble with finding the right correlationExpression to
> aggregate them.
> 
> Please can you help me fix this.
> 
> Thanks & regards,
> Ebe
> 


-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/correlationExpression-while-Aggregating-tp4975191p4975219.html
Sent from the Camel - Users mailing list archive at Nabble.com.