public class IfxSmartTrigger extends java.lang.Thread implements IfmxThreadedSmartTrigger
| Constructor and Description |
|---|
IfxSmartTrigger(javax.sql.DataSource source)
Creates a smart trigger object with a connection made by the provided datasource
|
IfxSmartTrigger(java.lang.String connectionUrl)
Creates a smart trigger object with a connection made by the provided URL
|
IfxSmartTrigger(java.lang.String connectionUrl,
java.util.Properties prop)
Creates a smart trigger object with a connection made by the provided URL
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTrigger(java.lang.String tableName,
java.lang.String tableOwnerName,
java.lang.String databaseName,
java.lang.String sqlQuery,
IfmxSmartTriggerCallback... callback)
Sets a watch on a particular table using a query using the default label
|
void |
addTrigger(java.lang.String tableName,
java.lang.String tableOwnerName,
java.lang.String databaseName,
java.lang.String sqlQuery,
java.lang.String label,
IfmxSmartTriggerCallback... callback)
Sets a watch on a particular table using a query using the default label
|
IfmxThreadedSmartTrigger |
buffer(int bufferSize)
Sets the buffer size for the data that will be held here in the client
This should be set to a size that will collect the number of records you can get at
a time as well as the 2 times the size of the JSON document that will be returned.
|
void |
close()
Attempts to shutdown the internal connection that is watching for events
If another thread is actively watching for events, this close is queued until
an event is triggered (an event can be an operation that the user is watching for
or a timeout event from the server).
|
IfmxThreadedSmartTrigger |
commitTime(long time)
Advanced option to restart your smart trigger from a commit time that was reported
from a prior Smart Trigger session
|
java.util.List<java.lang.String> |
getLabels()
Returns a list of labels currently registered as triggers in this object
|
IfmxThreadedSmartTrigger |
label(java.lang.String labelName)
Set a default label for all triggers created by this object
|
IfmxThreadedSmartTrigger |
maxRecordsPerRequest(int size)
Sets how many records can be returned in a single event call
This sets the maximum number of records returned if more than one record is sitting in the queue.
|
IfmxThreadedSmartTrigger |
operationsCacheSize(int size)
Sets the number of events/operations that the server will cache
The number set here will be how many events the server will cache waiting on
the client to retrieve them.
|
java.lang.String |
readTriggerEvent()
Reads a single smart trigger event from the server
|
void |
registerTriggers()
Registers all triggers that have been added/removed
This must be called before any calls to readTriggerEvent() as this method make the server side
calls to enable us to read the triggered events
|
void |
removeTrigger(java.lang.String label)
Removes one or more triggers based on the label provided
If you have already started the smart trigger, removing triggers will be queued until a
timeout or a trigger is executed.
|
void |
removeTrigger(java.lang.String tableName,
java.lang.String tableOwnerName,
java.lang.String databaseName)
Stops a trigger on a particular table/owner/database
If you have already started the smart trigger, removing triggers will be queued until a
timeout or a trigger is executed.
|
void |
run() |
IfmxThreadedSmartTrigger |
timeout(int timeout)
Sets the timeout for waiting for events from the server
If no event is triggered after this timeout, a timeout event is fired,
allowing the class to check if the user has made any changes to it's watch list
or requested the connection to the server to be closed.
|
IfmxThreadedSmartTrigger |
transactionID(long id)
Advanced option to restart your smart trigger from a transaction id that was reported
from a prior Smart Trigger session
|
void |
watch()
Starts watching for smart triggers
You must call this (or run() if you are executing this as a thread) to actually
start watching for smart triggers
This method will block forever, until the thread is interrupted or another thread
calls the close() method.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic IfxSmartTrigger(javax.sql.DataSource source)
throws java.sql.SQLException
source - A datasource object to make a connection withjava.sql.SQLExceptionpublic IfxSmartTrigger(java.lang.String connectionUrl)
throws java.sql.SQLException
connectionUrl - String URL which can be used to make a connectionjava.sql.SQLExceptionpublic IfxSmartTrigger(java.lang.String connectionUrl,
java.util.Properties prop)
throws java.sql.SQLException
connectionUrl - String URL which can be used to make a connectionprop - Connection properties you want passed into the connection that is createdjava.sql.SQLExceptionpublic void run()
run in interface java.lang.Runnablerun in class java.lang.Threadpublic IfmxThreadedSmartTrigger label(java.lang.String labelName)
label in interface IfmxThreadedSmartTriggerlabelName - A default label namepublic IfmxThreadedSmartTrigger timeout(int timeout)
timeout in interface IfmxThreadedSmartTriggertimeout - The timeout used for waiting for eventspublic IfmxThreadedSmartTrigger buffer(int bufferSize)
buffer in interface IfmxThreadedSmartTriggerbufferSize - Size in bytes for the buffer for this classpublic IfmxThreadedSmartTrigger operationsCacheSize(int size)
operationsCacheSize in interface IfmxThreadedSmartTriggersize - size of server side operations cachepublic IfmxThreadedSmartTrigger maxRecordsPerRequest(int size)
maxRecordsPerRequest in interface IfmxThreadedSmartTriggersize - records in a single requestpublic IfmxThreadedSmartTrigger commitTime(long time)
commitTime in interface IfmxThreadedSmartTriggertime - time value from a prior operations JSON document returned from a smart trigger objectpublic IfmxThreadedSmartTrigger transactionID(long id)
transactionID in interface IfmxThreadedSmartTriggerid - transaction idpublic void close()
throws java.sql.SQLException
close in interface IfmxThreadedSmartTriggerclose in interface java.lang.AutoCloseablejava.sql.SQLExceptionpublic void addTrigger(java.lang.String tableName,
java.lang.String tableOwnerName,
java.lang.String databaseName,
java.lang.String sqlQuery,
IfmxSmartTriggerCallback... callback)
throws java.sql.SQLException
Sets up a watch to a given table/owner/database using a simple SQL query. See the corresponding Informix documentation on which SQL Queries are valid.
You can pass in callback objects here or register callbacks later against a label using registerCallback(...) The user who is connected to the database from this class must have read permission on the table you are attempting to watch as well as sysadmin databse access. For details see the Informix server documentation. If you have already started the smart trigger, adding additional triggers will be queued until a timeout or a trigger is executed.
addTrigger in interface IfmxThreadedSmartTriggertableName - name of the table to watchtableOwnerName - owner of the tabledatabaseName - database the table resides insqlQuery - the SQL query that will validate if a change should trigger a messagecallback - a list of zero or more callback objects that will be executed when a trigger is fired.java.sql.SQLExceptionpublic void addTrigger(java.lang.String tableName,
java.lang.String tableOwnerName,
java.lang.String databaseName,
java.lang.String sqlQuery,
java.lang.String label,
IfmxSmartTriggerCallback... callback)
throws java.sql.SQLException
Sets up a watch to a given table/owner/database using a simple SQL query. See the corresponding Informix documentation on which SQL Queries are valid.
You can pass in callback objects here or register callbacks later against a label using registerCallback(...) The user who is connected to the database from this class must have read permission on the table you are attempting to watch as well as sysadmin databse access. For details see the Informix server documentation. If you have already started the smart trigger, adding additional triggers will be queued until a timeout or a trigger is executed.
addTrigger in interface IfmxThreadedSmartTriggertableName - name of the table to watchtableOwnerName - owner of the tabledatabaseName - database the table resides insqlQuery - the SQL query that will validate if a change should trigger a messagelabel - the label you want to use to identify/correlate one or more triggerscallback - a list of zero or more callback objects that will be executed when a trigger is fired.java.sql.SQLExceptionpublic void removeTrigger(java.lang.String tableName,
java.lang.String tableOwnerName,
java.lang.String databaseName)
throws java.sql.SQLException
removeTrigger in interface IfmxThreadedSmartTriggertableName - table to stop watchingtableOwnerName - owner of the tabledatabaseName - database where the table residesjava.sql.SQLExceptionpublic void removeTrigger(java.lang.String label)
throws java.sql.SQLException
removeTrigger in interface IfmxThreadedSmartTriggerlabel - label to removejava.sql.SQLExceptionpublic void registerTriggers()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.util.List<java.lang.String> getLabels()
getLabels in interface IfmxThreadedSmartTriggerpublic void watch()
throws java.sql.SQLException
watch in interface IfmxThreadedSmartTriggerjava.sql.SQLExceptionpublic java.lang.String readTriggerEvent()
throws java.sql.SQLException
java.sql.SQLException