org.apache.camel
Interface BatchConsumer

All Superinterfaces:
Consumer, Service
All Known Implementing Classes:
FileConsumer, FtpConsumer, GenericFileConsumer, IBatisConsumer, JpaConsumer, MailConsumer, MyBatisConsumer, RemoteFileConsumer, S3Consumer, SftpConsumer, SqsConsumer

public interface BatchConsumer
extends Consumer

A consumer of a batch of message exchanges from an Endpoint

Version:

Method Summary
 boolean isBatchAllowed()
          Whether processing the batch is still allowed.
 int processBatch(Queue<Object> exchanges)
          Processes the list of Exchange 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
getEndpoint
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

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 eg to 100 to avoid when starting and there are millions of messages for you in the first poll.

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 of Exchange 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 help indicate whether to complete the pending exchanges or stop after current exchange has been processed.

Returns:
true to continue processing from the batch, or false to stop.
See Also:
ShutdownRunningTask


Apache CAMEL