@NoImplement
public interface BatchTransactionContext
BatchJob processing blocks.
Each instance of this interface is strongly related to a particular BatchJobInstanceAdapter of one
BatchJobAdapter
Each contexts has a unique id. Implementantions are required to have their #equals(Object) and #hashCode()
implemented in a way consistent with this id. Every implementation must be able to be used as a key in a hash table| Modifier and Type | Method and Description |
|---|---|
void |
ackProcessedRecords(int howMany)
reports that
howMany records were successfully processed in this context (by successfully I mean without incidents. |
void |
ackSingleRecordProcessed()
reports that one record has been successfully processed in this context (by successfully I mean without incidents.
|
void |
beginTransaction()
Starts the transaction
|
void |
commit()
Commits the transaction
|
int |
getBlockSize() |
Serializable |
getId()
Returns an unmodifiable id associated to this particular instance
|
BatchJobAdapter |
getJob()
Returns the
BatchJobAdapter for which this context was built |
BatchJobInstanceAdapter |
getJobInstance()
Returns the
BatchJobInstanceAdapter for which this context was built |
org.mule.runtime.core.api.util.queue.Queue |
getQueue(String name)
Returns a
Queue attached to the current transaction |
CompletableFuture<Void> |
getResolutionCallback()
A
CompletableFuture which is completed when the transaction is resolved. |
boolean |
isBlockCompleted()
Returns
true if the total amount of acknowledged records through the ackProcessedRecords(int) matches the
block size. |
void |
rollback()
Rolls the transaction back
|
void |
setBlockSize(int size)
Sets the size of the record block this transaction is processingh
|
void |
updateJobInstance(BatchJobInstanceAdapter jobInstance)
Refreshes the state of the related
BatchJobInstanceAdapter |
void ackProcessedRecords(int howMany)
howMany records were successfully processed in this context (by successfully I mean without incidents.
The record might have failed or not, we don't care).
This method works in tandem with setBlockSize(int) and getBlockSize().howMany - the number of records that have been acknowledgedvoid ackSingleRecordProcessed()
ackProcessedRecords(int) with the number one as an argumentboolean isBlockCompleted()
true if the total amount of acknowledged records through the ackProcessedRecords(int) matches the
block size. Although it's not mandatory, you should call commit() when this method returns truetrue if all the Records in the block were acknowledged. false otherwisevoid beginTransaction()
throws org.mule.runtime.core.api.transaction.xa.ResourceManagerException
org.mule.runtime.core.api.transaction.xa.ResourceManagerExceptionvoid commit()
throws org.mule.runtime.core.api.transaction.xa.ResourceManagerException
org.mule.runtime.core.api.transaction.xa.ResourceManagerExceptionvoid rollback()
throws org.mule.runtime.core.api.transaction.xa.ResourceManagerException
org.mule.runtime.core.api.transaction.xa.ResourceManagerExceptionSerializable getId()
Serializable idBatchJobAdapter getJob()
BatchJobAdapter for which this context was builtnull BatchJobAdapterBatchJobInstanceAdapter getJobInstance()
BatchJobInstanceAdapter for which this context was builtnull BatchJobInstanceAdapterorg.mule.runtime.core.api.util.queue.Queue getQueue(String name)
Queue attached to the current transactionname - the name of the Queue you wantnull Queueint getBlockSize()
void updateJobInstance(BatchJobInstanceAdapter jobInstance)
BatchJobInstanceAdapterjobInstance - a not null BatchJobInstanceAdapterIllegalArgumentException - if the given BatchJobInstanceAdapter has a different id than the original
one or if it belongs to a different BatchJobAdaptervoid setBlockSize(int size)
size - the size of the record block this transaction is processingCompletableFuture<Void> getResolutionCallback()
CompletableFuture which is completed when the transaction is resolved. The future will be completed successfully
regardless of the transaction been committed or rolled back.
This will never complete if beginTransaction() is never invoked.
CompletableFutureCopyright © 2006–2022 MuleSoft, Inc.. All rights reserved.