org.jboss.soa.esb.listeners
Class SqlTablePoller

java.lang.Object
  extended by org.jboss.soa.esb.listeners.AbstractPoller
      extended by org.jboss.soa.esb.listeners.SqlTablePoller
All Implemented Interfaces:
java.lang.Runnable, java.util.Observer

public class SqlTablePoller
extends AbstractPoller

SqlTablePoller class The SQL table that is polled should have 1) a unique key (see "keyFields" parameter) that will be used to update status 2) a column to indicate the "processing status" of this trigger row (see ROW_STATE enum) Each retrieved row (see OPTIONAL_ATT.whereCondition) should be considered as a trigger that is intended to instantiate an object of "actionClass". The new instance will receive the full DomElement (level 1 for each child group)

Author:
Esteban Schifman

Nested Class Summary
static class SqlTablePoller.OPTIONAL_ATT
          Optional fields that can be included in your parameter tree as attributes in the upper Element 1) 4 character long String that indicate status of each row for this poller 1st: Character that indicates "Pending" state = available for processing 2nd: "Working" : some poller is working on the row (or ab-ended while working) 3rd: "Error" : some poller tried to process, and found an error during processing 4th: "Done" : this row has already been processed successfully 2) if you wish to further filter your ResultSet, you can add an optional list of conditions that will be included in the "scan" SQL statement (without "where") 3) Comma separated list of fields to order ResultSet (without "order by")
static class SqlTablePoller.ROW_STATE
          First character of these values are the default states of a table row trigger the "inProcessVals" parameter can override these (if that were ever necessary) this is why the default value for that parameter is "PWED" (see below) The poller will only process rows that have the "inProcessField" first character equal to the first character of whatever the "Pending" state is (typically "P")
static class SqlTablePoller.TABLE_ATT
          Mandatory attributes needed for SqlTablePoller 1) Table name 2) Comma separated list of fields needed in the ResultSet 3) Comma separated list of fields that constitute a unique ID of the working row all fields in this list MUST also be in the "selectFields" list these fields will be used in the "where" clause of update statements 4) Name of table field used as indicator/semaphore to avoid concurrent update
 
Field Summary
static java.lang.String DEFAULT_STATES
           
protected  java.util.Map<java.lang.String,java.lang.String> m_oVals
           
protected  java.lang.String[] m_saCols
           
protected  java.lang.String[] m_saKeys
           
protected  java.lang.String m_sUpdStates
           
 
Fields inherited from class org.jboss.soa.esb.listeners.AbstractPoller
m_iDfltPollMillis, m_iMaxThr, m_iMinPollMillis, m_iPollMillis, m_iQthr, m_iSleepForThreads, m_iUpperThreadLimit, m_oDad, m_oExecClass, m_oLogger, m_oParms, m_oThrGrp, PARM_POLL_LTCY
 
Constructor Summary
SqlTablePoller(GpListener p_oDad, DomElement p_oParms)
          In this constructor you can override default values for the following protected base class values:

m_iMinPollMillis : minimum polling interval (default 3000)
m_iDfltPollMillis : default polling interval (default 20000)
m_iSleepForThreads : how long to sleep if all configured threads are in use (default 3000)
m_iUpperThreadLimit : max number of threads allowed (default 10)

 
Method Summary
protected  void checkMyParms()
           
protected  JdbcCleanConn newDbConn()
          Obtain a new database connection with parameter info
protected  java.util.List<java.lang.Object> pollForCandidates()
           
protected  java.lang.Object preProcess(java.lang.Object p_o)
           
protected  java.lang.String scanStatement()
          Assemble the SQL statement to scan (poll) the table
protected  java.lang.String selectForUpdStatement()
          Assemble the SQL "select for update" statement for the "inProcessField" parameter in the table row uniquely identified by the list of fields in the "keyFields" parameter
protected  java.lang.String updateStatement()
          Assemble the SQL statement to update the field in the "inProcessField" parameter in the table row uniquely identified by the list of fields in the "keyFields" parameter
 
Methods inherited from class org.jboss.soa.esb.listeners.AbstractPoller
checkParms, run, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_STATES

public static final java.lang.String DEFAULT_STATES
See Also:
Constant Field Values

m_oVals

protected java.util.Map<java.lang.String,java.lang.String> m_oVals

m_saCols

protected java.lang.String[] m_saCols

m_saKeys

protected java.lang.String[] m_saKeys

m_sUpdStates

protected java.lang.String m_sUpdStates
Constructor Detail

SqlTablePoller

public SqlTablePoller(GpListener p_oDad,
                      DomElement p_oParms)
               throws java.lang.Exception
In this constructor you can override default values for the following protected base class values:

m_iMinPollMillis : minimum polling interval (default 3000)
m_iDfltPollMillis : default polling interval (default 20000)
m_iSleepForThreads : how long to sleep if all configured threads are in use (default 3000)
m_iUpperThreadLimit : max number of threads allowed (default 10)

Parameters:
p_oDad - GpListener - The controlling process
p_oParms - DomElement - Sub tree that corresponds to this instance
Throws:
java.lang.Exception
Method Detail

checkMyParms

protected void checkMyParms()
                     throws java.lang.Exception
Throws:
java.lang.Exception

preProcess

protected java.lang.Object preProcess(java.lang.Object p_o)
                               throws java.lang.Exception
Specified by:
preProcess in class AbstractPoller
Throws:
java.lang.Exception

pollForCandidates

protected java.util.List<java.lang.Object> pollForCandidates()
Specified by:
pollForCandidates in class AbstractPoller

newDbConn

protected JdbcCleanConn newDbConn()
                           throws java.lang.Exception
Obtain a new database connection with parameter info

Returns:
A new connection
Throws:
java.lang.Exception - - if problems are encountered

scanStatement

protected java.lang.String scanStatement()
Assemble the SQL statement to scan (poll) the table

Returns:
- The resulting SQL statement

updateStatement

protected java.lang.String updateStatement()
Assemble the SQL statement to update the field in the "inProcessField" parameter in the table row uniquely identified by the list of fields in the "keyFields" parameter

Returns:
- The resulting SQL statement

selectForUpdStatement

protected java.lang.String selectForUpdStatement()
Assemble the SQL "select for update" statement for the "inProcessField" parameter in the table row uniquely identified by the list of fields in the "keyFields" parameter

Returns:
- The resulting SQL statement