org.apache.camel.component.ibatis
Class IBatisPollingConsumer
java.lang.Object
org.apache.camel.impl.ServiceSupport
org.apache.camel.impl.DefaultConsumer
org.apache.camel.impl.ScheduledPollConsumer
org.apache.camel.component.ibatis.IBatisPollingConsumer
- All Implemented Interfaces:
- Runnable, org.apache.camel.BatchConsumer, org.apache.camel.Consumer, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.ShutdownAware, org.apache.camel.SuspendableService
public class IBatisPollingConsumer
- extends org.apache.camel.impl.ScheduledPollConsumer
- implements org.apache.camel.BatchConsumer, org.apache.camel.spi.ShutdownAware
Ibatis Camel Component used to read data from a database.
Example Configuration :
<route>
<from uri="ibatis:selectRecords" />
<to uri="jms:destinationQueue" />
</route>
This also can be configured to treat a table as a logical queue by defining
an "onConsume" statement.
Example Configuration :
<route>
<from uri="ibatis:selectRecords?consumer.onConsume=updateRecord" />
<to uri="jms:destinationQueue" />
</route>
By default, if the select statement contains multiple rows, it will
iterate over the set and deliver each row to the route. If this is not the
desired behavior then set "useIterator=false". This will deliver the entire
set to the route as a list.
URI Options
| Name |
Default Value |
description |
| initialDelay |
1000 ms |
time before polling starts |
| delay |
500 ms |
time before the next poll |
| timeUnit |
MILLISECONDS |
Time unit to use for delay properties (NANOSECONDS, MICROSECONDS,
MILLISECONDS, SECONDS) |
| useIterator |
true |
If true, processes one exchange per row. If false processes one exchange
for all rows |
| onConsume |
null |
statement to run after data has been processed |
- See Also:
IBatisProcessingStrategy
| Fields inherited from class org.apache.camel.impl.DefaultConsumer |
log |
| Methods inherited from class org.apache.camel.impl.ScheduledPollConsumer |
doStart, doStop, doSuspend, getDelay, getInitialDelay, getPollStrategy, getTimeUnit, isPollAllowed, isUseFixedDelay, run, setDelay, setInitialDelay, setPollStrategy, setTimeUnit, setUseFixedDelay |
| Methods inherited from class org.apache.camel.impl.DefaultConsumer |
getAsyncProcessor, getExceptionHandler, getProcessor, handleException, setExceptionHandler, toString |
| Methods inherited from class org.apache.camel.impl.ServiceSupport |
addChildService, doResume, doShutdown, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, start, stop, suspend |
| Methods inherited from interface org.apache.camel.Service |
start, stop |
| Methods inherited from interface org.apache.camel.SuspendableService |
isSuspended, resume, suspend |
shutdownRunningTask
protected volatile org.apache.camel.ShutdownRunningTask shutdownRunningTask
pendingExchanges
protected volatile int pendingExchanges
IBatisPollingConsumer
public IBatisPollingConsumer(IBatisEndpoint endpoint,
org.apache.camel.Processor processor)
throws Exception
- Throws:
Exception
getEndpoint
public IBatisEndpoint getEndpoint()
- Specified by:
getEndpoint in interface org.apache.camel.Consumer- Overrides:
getEndpoint in class org.apache.camel.impl.DefaultConsumer
poll
protected int poll()
throws Exception
- Polls the database
- Specified by:
poll in class org.apache.camel.impl.ScheduledPollConsumer
- Throws:
Exception
setMaxMessagesPerPoll
public void setMaxMessagesPerPoll(int maxMessagesPerPoll)
- Specified by:
setMaxMessagesPerPoll in interface org.apache.camel.BatchConsumer
processBatch
public int processBatch(Queue<Object> exchanges)
throws Exception
- Specified by:
processBatch in interface org.apache.camel.BatchConsumer
- Throws:
Exception
deferShutdown
public boolean deferShutdown(org.apache.camel.ShutdownRunningTask shutdownRunningTask)
- Specified by:
deferShutdown in interface org.apache.camel.spi.ShutdownAware
getPendingExchangesSize
public int getPendingExchangesSize()
- Specified by:
getPendingExchangesSize in interface org.apache.camel.spi.ShutdownAware
prepareShutdown
public void prepareShutdown()
- Specified by:
prepareShutdown in interface org.apache.camel.spi.ShutdownAware
isBatchAllowed
public boolean isBatchAllowed()
- Specified by:
isBatchAllowed in interface org.apache.camel.BatchConsumer
getOnConsume
public String getOnConsume()
- Gets the statement(s) to run after successful processing.
Use comma to separate multiple statements.
setOnConsume
public void setOnConsume(String onConsume)
- Sets the statement to run after successful processing.
Use comma to separate multiple statements.
isUseIterator
public boolean isUseIterator()
- Indicates how resultset should be delivered to the route
setUseIterator
public void setUseIterator(boolean useIterator)
- Sets how resultset should be delivered to route.
Indicates delivery as either a list or individual object.
defaults to true.
isRouteEmptyResultSet
public boolean isRouteEmptyResultSet()
- Indicates whether empty resultset should be allowed to be sent to the next hop or not
setRouteEmptyResultSet
public void setRouteEmptyResultSet(boolean routeEmptyResultSet)
- Sets whether empty resultset should be allowed to be sent to the next hop.
defaults to false. So the empty resultset will be filtered out.
Apache CAMEL