public interface IfmxThreadedSmartTrigger
extends java.lang.AutoCloseable, java.lang.Runnable
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.
|
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.lang.String |
detach()
Detach from this smart trigger session
You must have set
detachable(boolean) to true to enable this trigger to be detachable (12.10.xC9W1 or higher) |
IfmxThreadedSmartTrigger |
detachable(boolean detachable)
Designate whether this session can be detached
A detached session has a unique ID which can be referenced if this session closes
to restore the session and recover any records that might not have transferred.
|
java.lang.String |
getDetachableSesisonID()
Deprecated.
|
java.lang.String |
getDetachableSessionID()
Returns the ID for this session if it is detachable
If you use the
detachable(boolean) option to make this detachable (12.10.xC9W1 or higher)
calling this will return the session ID. |
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.
|
void |
registerCallback(java.lang.String label,
IfmxSmartTriggerCallback callback)
Registers a callback against an existing label
If you have already created a trigger with a label using
addTrigger(String, String, String, String, IfmxSmartTriggerCallback...)
or if you are re-connecting to a detached session, you can register just the callback methods against the label you designated. |
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.
|
IfmxThreadedSmartTrigger |
sessionID(java.lang.String id)
Sets the Smart Trigger session ID for us to connect to.
|
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
Runnable.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 AutoCloseable.close() method. |
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.
tableName
- 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.SQLException
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.
tableName
- 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.SQLException
IfmxThreadedSmartTrigger buffer(int bufferSize)
bufferSize
- Size in bytes for the buffer for this classIfmxThreadedSmartTrigger commitTime(long time)
time
- time value from a prior operations JSON document returned from a smart trigger objectIfmxThreadedSmartTrigger detachable(boolean detachable)
detachable
- whether the session is detachable (default false)java.lang.String detach() throws java.sql.SQLException
detachable(boolean)
to true to enable this trigger to be detachable (12.10.xC9W1 or higher)sessionID(String)
java.sql.SQLException
java.lang.String getDetachableSesisonID()
getDetachableSessionID()
java.lang.String getDetachableSessionID()
detachable(boolean)
option to make this detachable (12.10.xC9W1 or higher)
calling this will return the session ID. You can save this ID and reconnect to the session if you close
or get disconnectedjava.util.List<java.lang.String> getLabels()
IfmxThreadedSmartTrigger label(java.lang.String labelName)
labelName
- A default label nameIfmxThreadedSmartTrigger maxRecordsPerRequest(int size)
size
- records in a single requestIfmxThreadedSmartTrigger operationsCacheSize(int size)
size
- size of server side operations cachevoid registerCallback(java.lang.String label, IfmxSmartTriggerCallback callback)
addTrigger(String, String, String, String, IfmxSmartTriggerCallback...)
or if you are re-connecting to a detached session, you can register just the callback methods against the label you designated.
This can also be used to attach multiple callback methods to a single triggerlabel
- The existing label for an existing triggercallback
- Callback method/interface which will get executed when a trigger with the matching label is received.IfmxThreadedSmartTrigger timeout(int timeout)
timeout
- The timeout used for waiting for eventsIfmxThreadedSmartTrigger transactionID(long id)
id
- transaction idvoid removeTrigger(java.lang.String tableName, java.lang.String tableOwnerName, java.lang.String databaseName) throws java.sql.SQLException
tableName
- table to stop watchingtableOwnerName
- owner of the tabledatabaseName
- database where the table residesjava.sql.SQLException
void removeTrigger(java.lang.String label) throws java.sql.SQLException
label
- label to removejava.sql.SQLException
void watch() throws java.sql.SQLException
Runnable.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 AutoCloseable.close()
method.
Note if you set your timeout(int)
to zero, this will block until interrupted only. It will
never close on it's own. It's recommended to always have some timeout so the loop here
has a chance to take any actions, including adding/removing triggers or closing down.
As smart triggers are caught from the server, this call will route them to the appropriate
callback object you specified when you set up the smart trigger.
Missed records or timeouts are automatically sent to all callback objectsjava.sql.SQLException
IfmxThreadedSmartTrigger sessionID(java.lang.String id)
watch()
or Runnable.run()
Calling this method automatically sets detachable(boolean)
to true
id
- Smart Trigger/Push Data session ID to connect to