The function blocks described in this section can only be used in Python agents in batch workflows. The available function blocks are:
- beginBatch
- drain
- endBatch
- endBatchHinted
- cancelBatch
- splittingBatch
- commit
- rollback
beginBatch
Note!
This function block only applies for the Python processing agent.
This function block is executed at the beginning of each batch.
def beginBatch()
Example - beginBatch function block
def beginBatch(): debug('beginBatch called')
drain
Note!
This function block only applies for the Python processing agent.
This function block is called before the current batch ends. The agent must flush all internal buffers to make sure all pending data has been processed before the transaction is ended. This method is the last point in the batch processing where the agent is permitted to route data.
def drain()
Example - drain function block
def drain(): debug('drain called') udrRoute(myLastUDR)
endBatch
Note!
This function block only applies for the Python processing agent.
This function block is executed at the end of each batch.
def endBatch()
example - endBatch function block
def endBatch(): debug('endBatch called')
endBatchHinted
Note!
This function block only applies for the Python collection agent.
This function block is called when another agent has called hintEndBatch
. The collection agent may choose to ignore this method, that is, not to implement it if it cannot be supported.
def endBatchHinted()
Example - endBatchHinted function block
def endBatchHinted(): debug('endBatchHinted called')
cancelBatch
This function block is executed if a Cancel Batch is emitted anywhere in the workflow.
def cancelBatch()
Exampel - cancelBatch function block
def cancelBatch(): debug('cancelBatch called')
splittingBatch
Note!
This function block only applies for the Python processing agent.
This function block is called when the collection agent has split the input batch. If the agent keeps internal buffers to be flushed differently depending on the nature of the transaction, this method serves as a hint to the drain
call.
def splittingBatch()
Example - splittingBatch function block
def splittingBatch(): debug('splittingBatch called')
commit
This function block is executed for each batch when the transaction is successful. If the commit
block fails with an exception, it will be executed again until it succeeds.
def commit()
Example - commit function block
isRecoveryCommit = True def initialize(): debug('initialize called') def beginBatch(): global isRecoveryCommit isRecoveryCommit = False def commit(): if isRecoveryCommit: debug('this is a recovery commit, it is executed immediately after initialize') else: debug('this is a normal commit')
rollback
This function block is executed for a batch if it fails.
def rollback()
Example - rollback function block
def rollback(): debug('rollback called')
Add Comment