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 */ 017package org.apache.camel; 018 019/** 020 * Strategy that allows {@link Consumer}s to influence the {@link PollingConsumer}. 021 * <p/> 022 * For example this is used by schedule based consumers to be able to suspend/resume 023 * upon polling using a {@link PollingConsumer}. 024 * 025 * @see org.apache.camel.impl.EventDrivenPollingConsumer 026 */ 027public interface PollingConsumerPollingStrategy { 028 029 /** 030 * Callback invoked when the consumer is initialized such as when the {@link PollingConsumer} starts. 031 * 032 * @throws Exception can be thrown if error initializing. 033 */ 034 void onInit() throws Exception; 035 036 /** 037 * Callback invoked before the poll. 038 * 039 * @param timeout the timeout 040 * @throws Exception can be thrown if error occurred 041 * @return timeout to be used, this allows returning a higher timeout value 042 * to ensure at least one poll is being performed 043 */ 044 long beforePoll(long timeout) throws Exception; 045 046 /** 047 * Callback invoked after the poll. 048 * 049 * @throws Exception can be thrown if error occurred 050 */ 051 void afterPoll() throws Exception; 052}