Post Process
Custom Code that gets executed after every set of events posted to the output
Last updated
Custom Code that gets executed after every set of events posted to the output
Last updated
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;
}