Show Table of Contents
10.3. Polling Consumer
The polling consumer pattern, shown in Figure 10.2, “Polling Consumer Pattern”, is a pattern for implementing the consumer endpoint in a Apache Camel component, so it is only relevant to programmers who need to develop a custom component in Apache Camel. Existing components already have a consumer implementation pattern hard-wired into them.
Consumers that conform to this pattern expose polling methods,
receive(long timeout), and
receiveNoWait()that return a new exchange object, if one is available from the monitored resource. A polling consumer implementation must provide its own thread pool to perform the polling.
For more details about this implementation pattern, see Section 46.1.3, “Consumer Patterns and Threading”, Chapter 49, Consumer Interface, and Section 45.2, “Using the Consumer Template”.
Figure 10.2. Polling Consumer Pattern
Scheduled poll consumer
Many of the Apache Camel consumer endpoints employ a scheduled poll pattern to receive messages at the start of a route. That is, the endpoint appears to implement an event-driven consumer interface, but internally a scheduled poll is used to monitor a resource that provides the incoming messages for the endpoint.
See Section 49.2, “Implementing the Consumer Interface” for details of how to implement this pattern.
You can use the quartz component to provide scheduled delivery of messages using the Quartz enterprise scheduler. See chapter "Quartz" in "Apache Camel Component Reference" and Quartz Component for details.