Everytime the events are posted to the output, you can perform any post process, if need be, using the Post Process script. You can use any standard Java or Groovy code in the post process script.
Variables Available
The following are the variables available to the script
Variable
Description
Output Type
flowCode
Flow code
All
outputEventType
Table name in the target DB
All
inputEventType
Table/Object name in the source system
All
inputType
Input Connector Type e.g. Oracle, MySQL
All
outputType
Output Connector Type e.g. Oracle, MySQL
All
logger
Log4j logger for debug purpose
All
db
All
count
Total number of events processed
All
events
List of events List<Message>
All Database
errorCount
Total number of events erred out
All
con
Output database connection used to post the events
All Database
producer
The producer used to post the events
Kafka
key
S3 file Key used to post the events
Amazon S3
FlowScript (db)
FlowScrip.java
interface FlowScript {
/**
* <p>Call this to get a connection to the output database. Throws exception
* if the output type is not a database. If you call multiple times,
* then the same connection will be returned.</p>
*
* @return {@link IOConnection}
* @throws Exception
*/
IOConnection getTargetDBConnection() throws Exception;
/**
* <p>Call this to get a connection to the input database. Throws exception
* if the input type is not a database. If you call multiple times,
* then the same connection will be returned.</p>
*
* @return {@link IOConnection}
* @throws Exception
*/
IOConnection getSourceDBConnection() throws Exception;
/**
* <p>Call this to get a new connection to the output database, discarding any
* existing connection. Throws exception if the output type is not a database.
* If you call multiple times, then the same connection will be returned.</p>
*
* <p>This is useful when you want to make a Redshift call after an
* exception as shown below</p>
*
* <pre>
* Connection con = null;
*
* try {
*
* con = db.getTargetDBConnection();
*
* Map<Integer, Object> result = SQL.createCall(con, "my_proc(?, ?)")
* .bind(1, "bind value 1")
* .registerOutParameter(2, Types.VARCHAR2)
* .execute();
*
* } catch (Exception e) {
*
* con = db.resetAndGetTargetDBConnection();
*
* SQL.createCall(con, "my_handle_error_proc(?)")
* .bind(1, e.getMessage())
* .execute();
*
* }
* </pre>
* @return {@link IOConnection}
* @throws Exception
*/
IOConnection resetAndGetTargetDBConnection() throws Exception;
/**
* <p>Call this to get a new connection to the input database, discarding any
* existing connection. Throws exception if the input type is not a database.
* If you call multiple times, then the same connection will be returned.</p>
*
* <p>This is useful when you want to make a Redshift call after an
* exception as shown below</p>
*
* <pre>
* Connection con = null;
*
* try {
*
* con = db.getTargetDBConnection();
*
* Map<Integer, Object> result = SQL.createCall(con, "my_proc(?, ?)")
* .bind(1, "bind value 1")
* .registerOutParameter(2, Types.VARCHAR2)
* .execute();
*
* } catch (Exception e) {
*
* con = db.resetAndGetTargetDBConnection();
*
* SQL.createCall(con, "my_handle_error_proc(?)")
* .bind(1, e.getMessage())
* .execute();
*
* }
* </pre>
* @return {@link IOConnection}
* @throws Exception
*/
IOConnection resetAndGetSourceDBConnection() throws Exception;
/**
* This is called by FLOW after the script is executed
*/
void close();
/**
* This is called by FLOW after successful execution of the script to commit
* both the input and output connections when used.
*
* @throws SQLException
*/
void commit() throws SQLException;
/**
* This is called by FLOW after unsuccessful execution of the script to
* rollback both the input and output connections when used.
*
* @throws SQLException
*/
void rollback() throws Exception;
/**
* Same as logger.debug
* @param msg
*/
void debug(String msg);
/**
* Retrieves the value of a given variable
*
* @param variableName
* @return the variable value
* @throws Exception
*/
String env(String variableName) throws Exception;
}