Package org.apache.camel
Interface BatchConsumer
-
- All Superinterfaces:
AutoCloseable
,Consumer
,EndpointAware
,Service
public interface BatchConsumer extends Consumer
A consumer of a batch of message exchanges from anEndpoint
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
isBatchAllowed()
Whether processing the batch is still allowed.int
processBatch(Queue<Object> exchanges)
Processes the list ofExchange
objects in a batch.void
setMaxMessagesPerPoll(int maxMessagesPerPoll)
Sets a maximum number of messages as a limit to poll at each polling.-
Methods inherited from interface org.apache.camel.Consumer
getProcessor
-
Methods inherited from interface org.apache.camel.EndpointAware
getEndpoint
-
-
-
-
Method Detail
-
setMaxMessagesPerPoll
void setMaxMessagesPerPoll(int maxMessagesPerPoll)
Sets a maximum number of messages as a limit to poll at each polling. Can be used to limit e.g. to 100 to avoid reading thousands or more messages within the first polling at startup. Is default unlimited, but use 0 or negative number to disable it as unlimited.- Parameters:
maxMessagesPerPoll
- maximum messages to poll.
-
processBatch
int processBatch(Queue<Object> exchanges) throws Exception
Processes the list ofExchange
objects in a batch. Each message exchange will be processed individually but the batch consumer will add properties with the current index and total in the batch. The items in the Queue may actually be Holder objects that store other data alongside the Exchange.- Parameters:
exchanges
- list of items in this batch- Returns:
- number of messages actually processed
- Throws:
Exception
- if an internal processing error has occurred.
-
isBatchAllowed
boolean isBatchAllowed()
Whether processing the batch is still allowed. This is used during shutdown to indicate whether to complete the pending exchanges or stop after the current exchange has been processed.- Returns:
- true to continue processing from the batch, or false to stop.
- See Also:
ShutdownRunningTask
-
-