org.apache.camel.component.ibatis
Class IBatisPollingConsumer

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.impl.DefaultConsumer
          extended by org.apache.camel.impl.ScheduledPollConsumer
              extended by org.apache.camel.component.ibatis.IBatisPollingConsumer
All Implemented Interfaces:
Runnable, BatchConsumer, Consumer, Service, ShutdownableService, ShutdownAware, SuspendableService

public class IBatisPollingConsumer
extends ScheduledPollConsumer
implements BatchConsumer, 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

Field Summary
protected  int pendingExchanges
           
protected  ShutdownRunningTask shutdownRunningTask
           
 
Fields inherited from class org.apache.camel.impl.DefaultConsumer
log
 
Constructor Summary
IBatisPollingConsumer(IBatisEndpoint endpoint, Processor processor)
           
 
Method Summary
 boolean deferShutdown(ShutdownRunningTask shutdownRunningTask)
           
 IBatisEndpoint getEndpoint()
           
 String getOnConsume()
          Gets the statement(s) to run after successful processing.
 int getPendingExchangesSize()
           
 boolean isBatchAllowed()
           
 boolean isRouteEmptyResultSet()
          Indicates whether empty resultset should be allowed to be sent to the next hop or not
 boolean isUseIterator()
          Indicates how resultset should be delivered to the route
protected  void poll()
          Polls the database
 void processBatch(Queue<Object> exchanges)
           
 void setMaxMessagesPerPoll(int maxMessagesPerPoll)
           
 void setOnConsume(String onConsume)
          Sets the statement to run after successful processing.
 void setRouteEmptyResultSet(boolean routeEmptyResultSet)
          Sets whether empty resultset should be allowed to be sent to the next hop.
 void setUseIterator(boolean useIterator)
          Sets how resultset should be delivered to route.
 
Methods inherited from class org.apache.camel.impl.ScheduledPollConsumer
doStart, doStop, getDelay, getInitialDelay, getPollStrategy, getTimeUnit, isPollAllowed, isSuspended, isUseFixedDelay, resume, run, setDelay, setInitialDelay, setPollStrategy, setTimeUnit, setUseFixedDelay, suspend
 
Methods inherited from class org.apache.camel.impl.DefaultConsumer
getExceptionHandler, getProcessor, handleException, setExceptionHandler, toString
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, doShutdown, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, removeChildService, shutdown, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

Field Detail

shutdownRunningTask

protected volatile ShutdownRunningTask shutdownRunningTask

pendingExchanges

protected volatile int pendingExchanges
Constructor Detail

IBatisPollingConsumer

public IBatisPollingConsumer(IBatisEndpoint endpoint,
                             Processor processor)
                      throws Exception
Throws:
Exception
Method Detail

getEndpoint

public IBatisEndpoint getEndpoint()
Specified by:
getEndpoint in interface Consumer
Overrides:
getEndpoint in class DefaultConsumer

poll

protected void poll()
             throws Exception
Polls the database

Specified by:
poll in class ScheduledPollConsumer
Throws:
Exception

setMaxMessagesPerPoll

public void setMaxMessagesPerPoll(int maxMessagesPerPoll)
Specified by:
setMaxMessagesPerPoll in interface BatchConsumer

processBatch

public void processBatch(Queue<Object> exchanges)
                  throws Exception
Specified by:
processBatch in interface BatchConsumer
Throws:
Exception

deferShutdown

public boolean deferShutdown(ShutdownRunningTask shutdownRunningTask)
Specified by:
deferShutdown in interface ShutdownAware

getPendingExchangesSize

public int getPendingExchangesSize()
Specified by:
getPendingExchangesSize in interface ShutdownAware

isBatchAllowed

public boolean isBatchAllowed()
Specified by:
isBatchAllowed in interface 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.



Copyright © 2007-2010 IONA Open Source Community. All Rights Reserved.