META-INF.spring.camel-context.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of camel-example-aggregate Show documentation
Show all versions of camel-example-aggregate Show documentation
Demonstrates the persistent support for the Camel aggregator
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- START SNIPPET: e1 --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <!-- This is our aggregation strategy for the numbers received as input --> <bean id="myStrategy" class="org.apache.camel.example.NumberAggregationStrategy"/> <!-- This is the persistent repository to store aggregated messages --> <bean id="myRepo" class="org.apache.camel.component.hawtdb.HawtDBAggregationRepository"> <!-- use data/hawtdb.dat as the persistent store --> <property name="persistentFileName" value="data/hawtdb.dat"/> <!-- the repo must have an unique name, as you can have multiple repositories in the same file --> <property name="repositoryName" value="myCoolRepo"/> <!-- the repo file segment size --> <property name="bufferSize" value="602400"/> </bean> <!-- This is the Camel route which asks for input and aggregates incoming numbers --> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <!-- ask user to enter a number --> <from uri="stream:in?promptMessage=Enter a number to be added (enter STOP to end, and Ctrl-C to shutdown Camel): &promptDelay=1000"/> <!-- aggregate the input, use eagerCheckCompletion to let the completionPredicate easily detect the STOP command --> <aggregate strategyRef="myStrategy" aggregationRepositoryRef="myRepo" eagerCheckCompletion="true"> <!-- aggregate all messages into the same group --> <correlationExpression> <constant>true</constant> </correlationExpression> <!-- if end user enters STOP then complete the aggregation --> <completionPredicate> <simple>${body} contains 'STOP'</simple> </completionPredicate> <!-- and transform the completed message to a human readable --> <transform> <simple>The result is: ${body}</simple> </transform> <!-- which is printed on the console --> <to uri="stream:out"/> </aggregate> </route> </camelContext> </beans> <!-- END SNIPPET: e1 -->
© 2015 - 2024 Weber Informatics LLC | Privacy Policy