Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Stream requires the usage of a Long number for use as the sequencer. It will be enforced via gap detection, allowing us to compute if gaps exist. A gap is detected if a number in a series is missing, e.g. 3, 4, 6 with number 5 missing. Camel will back off the messages until number 5 arrives.

Java DSL with

...

Batch Example

As an example, suppose we needed to process stock quotes, every minute, and have them sequenced by their stock symbol. For this, we can use XPath as the expression to choose the correct stock symbol, and as the sort value.

Code Block
from("jms:topic:stock:quote")
        .resequence().xpath("/quote/@symbol")
        .timeout(60 * 1000)
        .to("seda:quotes");

NOTE: By default, it will use ascending sequence for the ordering. We do have the ability to develop our own comparison for sorting if required.

Java DSL with Stream Example

As an example of streaming, suppose we needed to continuously poll a file directory path for inventory updates on our products, and as an additional requirement it is important they are processed in sequence by their product id. To solve this, we can enable streaming and use one hour as the timeout.

Code Block
from("file://inventory")
        .resequence().xpath("/inventory/@sku")
        .stream().timeout(60 * 60 * 1000)
        .to("seda:inventoryUpdates");