Resequence

Table of Contents

Usage
Properties
Related topics

Resequences messages based on an expression

Usage

The Resequence pattern reorders messages according to a specified expression. It can be used in one of two modes:

  • batch — the resequencer collects the messages into a batch, resequences them and sends the batch to the target endpoint
  • stream — the resequencer looks for gaps in the message stream and resequences the messages between the gaps before sending them to the target endpoint

The Resequence pattern can be placed anywhere in the body of a route. It supports only a single output.

Properties

Table 50, “Resequence Properties” describes the properties you can specify using the properties editor.

Table 50. Resequence Properties

NameDescription

Language

Specifies the expression language used to process the expression.

Description

Specifies a text description for the node. This description is included in the generated XML file, but it is informational only. It is not used by Apache Camel.

Id

Specifies a unique identifier for the endpoint.

The tooling automatically generates an id for a node when it is created, but you can remove that id or replace it with your own. The Camel debugger requires all nodes with a breakpoint set to have a unique id.

You can use the id to refer to endpoints in your Camel XML file.

Resequencer Config

Specifies the configuration for the resequencer:

  • batch-config — configures batch processing mode, in which messages are collected into batches, sorted, and then output accordingly.
  • stream-config — configures stream processing mode, in which messages are contunuously reorderd and output based on gaps detected between them.

Configure only one mode.


batch-config configuration Table 51, “batch-config Properties” describes the properties you can specify using the properties editor.

Table 51. batch-config Properties

NameDescription

Allow Duplicates

Specifies whether the resequencer keeps duplicate messages (those having the same message expression). The default is Disabled, which forces the resequencer to keep only the last duplicate message.

Batch Size

Specifies the number of messages to include in the batch. The default is 100.

Batch Timeout

Specifies the amount of time, in milliseconds, the node will attempt to batch up the messages before timing out. The default is 1000.

Ignore Invalid Exchanges

Specifies whether the resequencer ignores invalid exchanges, those for which it cannot evaluate the specified expression. The default is Disabled, which results in the resequencer throwing a CamelExchangeException when it encounters an invalid exchange.

Reverse

Specifies whether to reverse the priority of output based on expression ordering. By default, expression ordering is 0 → 9/A → Z, with highest priority given to lowest order expressions. The default is Disabled. For details, see Resequencer.


stream-config configuration Table 52, “stream-config Properties” describes the properties you can specify using the properties editor.

Table 52. stream-config Properties

NameDescription

Capacity

Specifies the maximum number of messages that can be stored in the node’s memory while it waits to receive out-of-sequence messages.

This property is used to prevent the node from running out of memory when it detects gaps in the message stream. In general, when using a large timeout value, set the capacity value sufficiently high to accommodate it (for example, <stream-config capacity="5000" timeout="4000" />).

The default is 1000.

Comparator Ref

Specifies a reference to the bean that implements the ording alorithm for the custom sequence number format. For details, see Resequencer.

Ignore Invalid Exchanges

Specifies whether the resequencer ignores invalid exchanges, those for which it cannot evaluate the specified expression. The default is Disabled, which results in the resequencer throwing a CamelExchangeException when it encounters an invalid exchange.

Timeout

Specifies the amount of time, in milliseconds, the node will wait to receive an out-of-sequence message before timing out.

If you know the max time difference between successive messages in the stream, set the timeout to that value. Doing so guarantees that all messages in the stream will be delivered in the correct order to the next node in the route. The lower the timeout value compared to the out-of-sequence time difference, the greater the probability of out-of-sequence message delivery.

The default is 1000.


Related topics