use of com.hazelcast.jet.impl.processor.TransactionPoolSnapshotUtility in project hazelcast by hazelcast.
the class WriteKafkaP method init.
@Override
public void init(@Nonnull Outbox outbox, @Nonnull Context context) {
this.context = context;
ProcessingGuarantee guarantee = context.processingGuarantee() == EXACTLY_ONCE && !exactlyOnce ? AT_LEAST_ONCE : context.processingGuarantee();
snapshotUtility = new TransactionPoolSnapshotUtility<>(outbox, context, false, guarantee, TXN_POOL_SIZE, (processorIndex, txnIndex) -> new KafkaTransactionId(context.jobId(), context.jobConfig().getName(), context.vertexName(), processorIndex, txnIndex), txnId -> {
if (txnId != null) {
properties.put("transactional.id", txnId.getKafkaId());
}
return new KafkaTransaction<>(txnId, properties, context.logger());
}, txnId -> {
try {
recoverTransaction(txnId, true);
} catch (ProducerFencedException e) {
context.logger().warning("Failed to finish the commit of a transaction ID saved in the " + "snapshot, data loss can occur. Transaction id: " + txnId.getKafkaId(), e);
}
}, txnId -> recoverTransaction(txnId, false));
}
Aggregations