Architecture

Batch Consumer

qianmoQqianmoQ· 更新于 2026-09-22· 阅读 7 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

Batch Consumer

Batch Consumer is basically a Polling Consumer that is capable of polling multiple Exchanges in a single pool.

To support batching the consumer must implement the org.apache.camel.BatchConsumer interface.

A range of Camel components support batching such as:

Options

The BatchConsumer supports the following options:

OptionDescription
maxMessagesPerPollAn integer to define a maximum messages to gather per poll. By default, no maximum is set. It can be used to set a limit of e.g., 1000 to avoid when starting up the server that there are thousands of files. Set a value of 0 or negative to disable it as unlimited.

Very often a BatchConsumer is scheduled and is based of the ScheduledBatchPollingConsumer that has many options for configuring the scheduling. These options are listed with (scheduler) as label in the endpoint options' in the Components documentation.

Exchange Properties

The following properties are set on the Exchange for each Exchange polled in the same batch.

PropertyDescription
CamelBatchSizeThe total number of Exchanges that was polled in this batch.
CamelBatchIndexThe current index of the batch. Starts from 0.
CamelBatchCompleteA boolean indicating the last Exchange in the batch. Is only true for the last entry.

评论

登录后参与评论

正在加载评论…