public abstract class TransactionalQueueBuffer extends AbstractRecordBuffer implements BatchContextTransactionManager
RecordBuffer that writes to a Queue when flushed. Abstract method
getDelegate(com.mulesoft.mule.runtime.module.batch.engine.BatchJobInstanceAdapter) allows specifying the target queue
using the BatchQueueDelegate abstraction.
When this buffer is flushed, it will attempt writing to a persistent queue using a
BatchTransactionContext. If the queue is successfully
written, then the transaction context will be committed. Otherwise it will be rolled back| Modifier and Type | Field and Description |
|---|---|
protected BatchQueueManager |
batchQueueManager |
| Modifier | Constructor and Description |
|---|---|
protected |
TransactionalQueueBuffer(String name,
BatchEngine batchEngine) |
| Modifier and Type | Method and Description |
|---|---|
int |
add(BatchJobInstanceAdapter jobInstance,
BatchTransactionContext ctx,
Record record)
buffers the given
Record for the given BatchJobInstanceAdapter |
void |
commit(BatchTransactionContext context)
commit
|
protected void |
doFlush(BatchJobInstanceAdapter jobInstance,
BatchTransactionContext ctx,
List<Record> records) |
protected void |
doForget(BatchJobInstanceAdapter jobInstance) |
void |
flush(BatchJobInstanceAdapter jobInstance)
Flushes the buffered
Records for the given
BatchJobInstanceAdapter. |
void |
flushAndForget(BatchJobInstanceAdapter jobInstance)
|
void |
forget(BatchJobInstanceAdapter jobInstance)
Releases all tracking information for the given
BatchJobInstanceAdapter |
protected abstract BatchQueueDelegate |
getDelegate(BatchJobInstanceAdapter jobInstance)
Returns the
BatchQueueDelegate through which information will be written into the queue |
void |
rollback(BatchTransactionContext ctx,
BatchJobInstanceAdapter jobInstance,
List<Record> records,
org.mule.runtime.api.exception.MuleException e)
rollback
|
long |
size(BatchJobInstanceAdapter jobInstance)
Returns how many records are buffered for the given
BatchJobInstanceAdapter |
add, getNameprotected final BatchQueueManager batchQueueManager
protected TransactionalQueueBuffer(String name, BatchEngine batchEngine)
public int add(BatchJobInstanceAdapter jobInstance, BatchTransactionContext ctx, Record record)
Record for the given BatchJobInstanceAdapteradd in interface RecordBufferjobInstance - a BatchJobInstanceAdapterrecord - a Recordpublic void flush(BatchJobInstanceAdapter jobInstance)
Records for the given
BatchJobInstanceAdapter.
Use this method when you want to flush the info but you still expect more records from the same job instance to come. In this
way, you flush the records but you avoid constantly recreating the internal tracking information.
This is a thread-safe operation.flush in interface RecordBufferjobInstance - the BatchJobInstanceAdapter which records you want
flushedprotected void doFlush(BatchJobInstanceAdapter jobInstance, BatchTransactionContext ctx, List<Record> records)
public void forget(BatchJobInstanceAdapter jobInstance)
BatchJobInstanceAdapterforget in interface RecordBufferjobInstance - a BatchJobInstanceAdapter which you no longer need
to trackprotected void doForget(BatchJobInstanceAdapter jobInstance)
public void flushAndForget(BatchJobInstanceAdapter jobInstance)
RecordBuffer.flush(com.mulesoft.mule.runtime.module.batch.engine.BatchJobInstanceAdapter) followed by a
RecordBuffer.forget(com.mulesoft.mule.runtime.module.batch.engine.BatchJobInstanceAdapter).
You MUST use this method when you know that the given jobInstance will no longer be executed in order to avoid a
memory leak on its tracking information
This is NOT a thread-safe operation. You must be careful to not have several threads invoking this method at the same
time for the same BatchJobInstanceAdapterflushAndForget in interface RecordBufferjobInstance - a BatchJobInstanceAdapter which you no longer need
to trackpublic long size(BatchJobInstanceAdapter jobInstance)
BatchJobInstanceAdaptersize in interface RecordBufferjobInstance - a BatchJobInstanceAdapterprotected abstract BatchQueueDelegate getDelegate(BatchJobInstanceAdapter jobInstance)
BatchQueueDelegate through which information will be written into the queueBatchQueueDelegatepublic void commit(BatchTransactionContext context)
BatchContextTransactionManagercommit in interface BatchContextTransactionManagercontext - a batch transaction contextpublic void rollback(BatchTransactionContext ctx, BatchJobInstanceAdapter jobInstance, List<Record> records, org.mule.runtime.api.exception.MuleException e)
BatchContextTransactionManagerrollback in interface BatchContextTransactionManagerctx - a batch transaction contextjobInstance - a job Iinstancerecords - a list o recordse - an exceptionCopyright © 2006–2022 MuleSoft, Inc.. All rights reserved.