Namespace: OpenEdge.Messaging
Type: Interface ITransactionalProducer
Parent Classes:
Inherits: OpenEdge.Messaging.IProducer


/*
Copyright © 2022 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Purpose:
The transactional producer interface defines the methods that a producer needs
to work with transactions. Transactional producers have methods that control the transaction
boundaries that are not needed with regular record producers.
The implementation relies on the behavior of the underlying library. You can read more about
how the Kafka library behaves here:
https://github.com/edenhill/librdkafka/blob/master/src/rdkafka.h



Method Summary
  Options Name Purpose
  AbortTransaction () /** Abort the current transaction. If any exception occurs, you can retry the abort, or delete the producer. You cannot commit a transaction once an attempt has been made to abort it; the abort may be retried, or the producer must be deleted. This method will block until all outstanding messages are purged, and transaction abort is successful or until the timeout occurs. The timeout is based on the 'transaction.timeout.ms' option configured for the producer. The application may retry this operation if MessagingErrorRetriable is raised. This method may raise one or more of the following errors: @throws Progress.Messaging.MessagingError @throws Progress.Lang.MessagingErrorRetriable @throws Progress.Lang.MessagingErrorFatal @throws Progress.Lang.MessagingErrorAbort */
  BeginTransaction () /** Begin a transaction. Only one active transaction per producer is allowed. Messages may not be produced outside of the transaction boundary. This method is blocking, but may timeout. The timeout is based on the 'transaction.timeout.ms' option configured for the producer. This method may raise one or more of the following errors: @throws Progress.Messaging.MessagingError @throws Progress.Lang.MessagingErrorRetriable @throws Progress.Lang.MessagingErrorFatal @throws Progress.Lang.MessagingErrorAbort */
  CommitTransaction () /** Commit the current transaction. If any exception occurs, you can retry the commit or delete the producer. You cannot abort any transaction once an attempt has been made to commit it; the commit may be retried, or the producer must be deleted. Flush is automatically called. This method will block until all outstanding messages are delivered, and transaction commit request is successful or until the timeout occurs. The timeout is based on the 'transaction.timeout.ms' option configured for the producer. The application may retry this operation if MessagingErrorRetriable is raised. This method may raise one or more of the following errors: @throws Progress.Messaging.MessagingError @throws Progress.Lang.MessagingErrorRetriable @throws Progress.Lang.MessagingErrorFatal @throws Progress.Lang.MessagingErrorAbort */
  InitTransactions () /** Called to ensure any previously opened transactions are fenced off from new transactions that are using the transactional.id of the producer. This method must be called before BeginTransaction in order to prepare the client and Kafka cluster for handling transactions from the producer. This method is blocking, but may timeout. The timeout is based on the 'transaction.timeout.ms' option configured for the producer. The application may retry this operation if MessagingErrorRetriable is raised. @throws Progress.Messaging.MessagingError @throws Progress.Lang.MessagingErrorRetriable @throws Progress.Lang.MessagingErrorFatal @throws Progress.Lang.MessagingErrorAbort */
  SendOffsetsToTransaction (IList, IConsumer) /** SendOffsetsToTransaction is used to record the offsets for a consumer within the transaction used to produce records. The offsets are sent to the cluster and recorded as part of the current transaction. SendOffsetsToTransaction is used in a "consume->process->produce" scenario where the producer wants to ensure that offset acknowledgements for consumed records are stored with the broker if the transaction is successfully committed. This method is used when a process is both a consumer of records and a producer of records. This method is called passing in the offsets and partition metadata related to any consumed messages before the transaction is completed. The consumer must be configured with isolation.level=read_committed and enable.auto.commit=false, and the application must not call CommitOffset on the consumer. The recording of consumer offsets via SendOffsetToTransaction or SendOffsetsToTransaction may only be done once per transaction. @param offsets List of Topic+Partition+Offset to commit to the consumer group upon successful commit of the transaction. Offsets should be the next message to consume, e.g., offset of last processed message + 1. @param consumer The consumer client that is consuming messages within the transaction This method may raise one or more of the following errors: @throws Progress.Messaging.MessagingError @throws Progress.Lang.MessagingErrorRetriable @throws Progress.Lang.MessagingErrorFatal @throws Progress.Lang.MessagingErrorAbort */
  SendOffsetToTransaction (TopicPartitionOffset, IConsumer) /** SendOffsetToTransaction is used to record the offsets for a consumer within the transaction used to produce records. The offsets are sent to the cluster and recorded as part of the current transaction. SendOffsetToTransaction is used in a "consume->process->produce" scenario where the producer wants to ensure that offset acknowledgements for consumed records are stored with the broker if the transaction is successfully committed. This method is used when a process is both a consumer of records and a producer of records. This method is called passing in the offset and partition metadata related to any consumed messages before the transaction is completed. The consumer must be configured with isolation.level=read_committed and enable.auto.commit=false, and the application must not call CommitOffset on the consumer. The recording of consumer offsets via SendOffsetToTransaction or SendOffsetsToTransaction may only be done once per transaction. @param offsets Topic+Partition+Offset to commit to the consumer group upon successful commit of the transaction. The offset should be the next message to consume, e.g., offset of last processed message + 1. @param consumer The consumer client that is consuming messages within the transaction This method may raise one or more of the following errors: @throws Progress.Messaging.MessagingError @throws Progress.Lang.MessagingErrorRetriable @throws Progress.Lang.MessagingErrorFatal @throws Progress.Lang.MessagingErrorAbort */

Method Detail
Top

AbortTransaction ()

Purpose:
Abort the current transaction. If any exception occurs, you can retry the abort, or delete the producer.
You cannot commit a transaction once an attempt has been made to abort it; the abort may be retried, or the producer must be deleted.
This method will block until all outstanding messages are purged, and transaction abort is successful or until the timeout occurs.
The timeout is based on the 'transaction.timeout.ms' option configured for the producer.
The application may retry this operation if MessagingErrorRetriable is raised.
This method may raise one or more of the following errors:
@throws Progress.Messaging.MessagingError
@throws Progress.Lang.MessagingErrorRetriable
@throws Progress.Lang.MessagingErrorFatal
@throws Progress.Lang.MessagingErrorAbort
Top

BeginTransaction ()

Purpose:
Begin a transaction. Only one active transaction per producer is allowed. Messages may not be produced outside of the transaction
boundary.
This method is blocking, but may timeout. The timeout is based on the 'transaction.timeout.ms' option configured for the producer.
This method may raise one or more of the following errors:
@throws Progress.Messaging.MessagingError
@throws Progress.Lang.MessagingErrorRetriable
@throws Progress.Lang.MessagingErrorFatal
@throws Progress.Lang.MessagingErrorAbort
Top

CommitTransaction ()

Purpose:
Commit the current transaction. If any exception occurs, you can retry the commit or delete the producer.
You cannot abort any transaction once an attempt has been made to commit it; the commit may be retried, or the producer must be deleted.
Flush is automatically called.
This method will block until all outstanding messages are delivered, and transaction commit request is successful or until the timeout occurs.
The timeout is based on the 'transaction.timeout.ms' option configured for the producer.
The application may retry this operation if MessagingErrorRetriable is raised.
This method may raise one or more of the following errors:
@throws Progress.Messaging.MessagingError
@throws Progress.Lang.MessagingErrorRetriable
@throws Progress.Lang.MessagingErrorFatal
@throws Progress.Lang.MessagingErrorAbort
Top

InitTransactions ()

Purpose:
Called to ensure any previously opened transactions are fenced off from new transactions that are using the
transactional.id of the producer. This method must be called before BeginTransaction in order to prepare the client and Kafka cluster
for handling transactions from the producer.
This method is blocking, but may timeout. The timeout is based on the 'transaction.timeout.ms' option configured for the producer.
The application may retry this operation if MessagingErrorRetriable is raised.
@throws Progress.Messaging.MessagingError
@throws Progress.Lang.MessagingErrorRetriable
@throws Progress.Lang.MessagingErrorFatal
@throws Progress.Lang.MessagingErrorAbort
Top

SendOffsetsToTransaction (IList, IConsumer)

Purpose:
SendOffsetsToTransaction is used to record the offsets for a consumer within the transaction used to produce records. The offsets are sent to
the cluster and recorded as part of the current transaction.
SendOffsetsToTransaction is used in a "consume->process->produce" scenario where the producer wants to ensure that offset acknowledgements
for consumed records are stored with the broker if the transaction is successfully committed. This method is used when a process is both
a consumer of records and a producer of records. This method is called passing in the offsets and partition metadata related to any
consumed messages before the transaction is completed.
The consumer must be configured with isolation.level=read_committed and enable.auto.commit=false, and the application must not call CommitOffset on the consumer.
The recording of consumer offsets via SendOffsetToTransaction or SendOffsetsToTransaction may only be done once per transaction.
successful commit of the transaction. Offsets should be
the next message to consume, e.g., offset of last processed message + 1.
This method may raise one or more of the following errors:
@throws Progress.Messaging.MessagingError
@throws Progress.Lang.MessagingErrorRetriable
@throws Progress.Lang.MessagingErrorFatal
@throws Progress.Lang.MessagingErrorAbort
Parameters:
offsets IList
  List of Topic+Partition+Offset to commit to the consumer group upon
consumer OpenEdge.Messaging.IConsumer
  The consumer client that is consuming messages within the transaction
Top

SendOffsetToTransaction (TopicPartitionOffset, IConsumer)

Purpose:
SendOffsetToTransaction is used to record the offsets for a consumer within the transaction used to produce records. The offsets are sent to
the cluster and recorded as part of the current transaction.
SendOffsetToTransaction is used in a "consume->process->produce" scenario where the producer wants to ensure that offset acknowledgements
for consumed records are stored with the broker if the transaction is successfully committed. This method is used when a process is both
a consumer of records and a producer of records. This method is called passing in the offset and partition metadata related to any
consumed messages before the transaction is completed.
The consumer must be configured with isolation.level=read_committed and enable.auto.commit=false, and the application must not call CommitOffset on the consumer.
The recording of consumer offsets via SendOffsetToTransaction or SendOffsetsToTransaction may only be done once per transaction.
successful commit of the transaction. The offset should be
the next message to consume, e.g., offset of last processed message + 1.
This method may raise one or more of the following errors:
@throws Progress.Messaging.MessagingError
@throws Progress.Lang.MessagingErrorRetriable
@throws Progress.Lang.MessagingErrorFatal
@throws Progress.Lang.MessagingErrorAbort
Parameters:
offset OpenEdge.Messaging.TopicPartitionOffset
 
consumer OpenEdge.Messaging.IConsumer
  The consumer client that is consuming messages within the transaction