001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.camel; 018 019 import java.util.Queue; 020 021 /** 022 * A consumer of a batch of message exchanges from an {@link Endpoint} 023 * 024 * @version $Revision: 782062 $ 025 */ 026 public interface BatchConsumer extends Consumer { 027 028 /** 029 * Sets a maximum number of messages as a limit to poll at each polling. 030 * <p/> 031 * Can be used to limit eg to 100 to avoid when starting and there are millions 032 * of messages for you in the first poll. 033 * <p/> 034 * Is default unlimited, but use 0 or negative number to disable it as unlimited. 035 * 036 * @param maxMessagesPerPoll maximum messages to poll. 037 */ 038 void setMaxMessagesPerPoll(int maxMessagesPerPoll); 039 040 /** 041 * Processes the list of {@link org.apache.camel.Exchange} in a batch. 042 * <p/> 043 * Each message exchange will be processed individually but the batch 044 * consumer will add properties with the current index and total in the batch. 045 * 046 * @param exchanges list of exchanges in this batch 047 * @throws Exception if an internal processing error has occurred. 048 */ 049 void processBatch(Queue exchanges) throws Exception; 050 051 }