Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

The persistent datastore is located in the data/hawtdb.dat file. Its automatic created the first time.

Example

For example we start the example for the first time using mvn camel:run and then we enter the two numbers 5 and 7 before we shutdown using ctrl + c. The relevant console output:

Code Block

[pache.camel.spring.Main.main()] DefaultCamelContext            INFO  Apache Camel 2.3-SNAPSHOT (CamelContext:camel) started
Enter a number to be added (use STOP to end, and ctrl c to shutdown Camel): 5
Enter a number to be added (use STOP to end, and ctrl c to shutdown Camel): 7
Enter a number to be added (use STOP to end, and ctrl c to shutdown Camel): ^C[                      Thread-2] Main$HangupInterceptor         INFO  Received hang up - stopping the main instance.
[                      Thread-2] MainSupport                    INFO  Apache Camel 2.3-SNAPSHOT stopping

Now we start the example again using mvn camel:run and enter the number 3 and then enter STOP to see the result. As expected the result is 5+7+3 = 15 as outputted on the console. As you can see the persistence of the aggregated messages ensures we could continue where we stopped.

Code Block

[pache.camel.spring.Main.main()] DefaultCamelContext            INFO  Apache Camel 2.3-SNAPSHOT (CamelContext:camel) started
Enter a number to be added (use STOP to end, and ctrl c to shutdown Camel): 3
Enter a number to be added (use STOP to end, and ctrl c to shutdown Camel): STOP
The result is: 15
Enter a number to be added (use STOP to end, and ctrl c to shutdown Camel): 

Using Aggregator

The example is configured as follows in Spring XML.TODO: e1

Wiki Markup
{snippet:id=e1|lang=xml|url=camel/trunk/examples/camel-example-aggregate/src/main/resources/META-INF/spring/camel-context.xml}

And it has a AggregationStrategy to sum the numbers which is done in Java code as:TODO: e1

Wiki Markup
{snippet:id=e1|lang=java|url=camel/trunk/examples/camel-example-aggregate/src/main/java/org/apache/camel/example/NumberAggregationStrategy.java}

See Also