public class DefaultBatchTransactionContext extends Object implements BatchTransactionContext
BatchTransactionContext| Constructor and Description |
|---|
DefaultBatchTransactionContext(BatchJobAdapter job,
BatchJobInstanceAdapter jobInstance,
org.mule.runtime.core.api.util.queue.QueueSession queueSession) |
| 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
|
boolean |
equals(Object obj) |
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. |
int |
hashCode() |
boolean |
isBlockCompleted()
Returns
true if the total amount of acknowledged records through the BatchTransactionContext.ackProcessedRecords(int) matches the
block size. |
void |
rollback()
Rolls the transaction back
|
void |
setBlockSize(int blockSize)
Sets the size of the record block this transaction is processingh
|
void |
updateJobInstance(BatchJobInstanceAdapter jobInstance)
Refreshes the state of the related
BatchJobInstanceAdapter |
public DefaultBatchTransactionContext(BatchJobAdapter job, BatchJobInstanceAdapter jobInstance, org.mule.runtime.core.api.util.queue.QueueSession queueSession)
public 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 BatchTransactionContext.setBlockSize(int) and BatchTransactionContext.getBlockSize().ackProcessedRecords in interface BatchTransactionContexthowMany - the number of records that have been acknowledgedpublic void ackSingleRecordProcessed()
BatchTransactionContext.ackProcessedRecords(int) with the number one as an argumentackSingleRecordProcessed in interface BatchTransactionContextpublic boolean isBlockCompleted()
true if the total amount of acknowledged records through the BatchTransactionContext.ackProcessedRecords(int) matches the
block size. Although it's not mandatory, you should call BatchTransactionContext.commit() when this method returns trueisBlockCompleted in interface BatchTransactionContexttrue if all the Records in the block were acknowledged. false otherwisepublic void updateJobInstance(BatchJobInstanceAdapter jobInstance)
BatchJobInstanceAdapterupdateJobInstance in interface BatchTransactionContextjobInstance - a not null BatchJobInstanceAdapterpublic int getBlockSize()
getBlockSize in interface BatchTransactionContextpublic void setBlockSize(int blockSize)
setBlockSize in interface BatchTransactionContextblockSize - the size of the record block this transaction is processingpublic void commit()
throws org.mule.runtime.core.api.transaction.xa.ResourceManagerException
commit in interface BatchTransactionContextorg.mule.runtime.core.api.transaction.xa.ResourceManagerExceptionpublic void beginTransaction()
throws org.mule.runtime.core.api.transaction.xa.ResourceManagerException
beginTransaction in interface BatchTransactionContextorg.mule.runtime.core.api.transaction.xa.ResourceManagerExceptionpublic void rollback()
throws org.mule.runtime.core.api.transaction.xa.ResourceManagerException
rollback in interface BatchTransactionContextorg.mule.runtime.core.api.transaction.xa.ResourceManagerExceptionpublic Serializable getId()
getId in interface BatchTransactionContextSerializable idpublic BatchJobAdapter getJob()
BatchJobAdapter for which this context was builtgetJob in interface BatchTransactionContextnull BatchJobAdapterpublic BatchJobInstanceAdapter getJobInstance()
BatchJobInstanceAdapter for which this context was builtgetJobInstance in interface BatchTransactionContextnull BatchJobInstanceAdapterpublic CompletableFuture<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 BatchTransactionContext.beginTransaction() is never invoked.
getResolutionCallback in interface BatchTransactionContextCompletableFuturepublic org.mule.runtime.core.api.util.queue.Queue getQueue(String name)
BatchTransactionContextQueue attached to the current transactiongetQueue in interface BatchTransactionContextname - the name of the Queue you wantnull QueueCopyright © 2006–2022 MuleSoft, Inc.. All rights reserved.