Interface PulsarTransactions<T>
- All Superinterfaces:
io.smallrye.reactive.messaging.EmitterType
- All Known Implementing Classes:
PulsarTransactionsImpl
-
Method Summary
Modifier and TypeMethodDescriptionboolean<M extends org.eclipse.microprofile.reactive.messaging.Message<? extends T>>
voidsend(TransactionalEmitter<?> emitter, M msg) Send message to an already started transactionvoidsend(TransactionalEmitter<?> emitter, T payload) Send message to an already started transaction<R> io.smallrye.mutiny.Uni<R>withTransaction(Duration txnTimeout, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<R>> work) Produce records in a Pulsar transaction.<R> io.smallrye.mutiny.Uni<R>withTransaction(Duration txnTimeout, org.eclipse.microprofile.reactive.messaging.Message<?> message, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<R>> work) Produce records in a Pulsar transaction, by processing the given message exactly-once.<R> io.smallrye.mutiny.Uni<R>withTransaction(Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<R>> work) Produce records in a Pulsar transaction.<R> io.smallrye.mutiny.Uni<R>withTransaction(org.eclipse.microprofile.reactive.messaging.Message<?> message, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<R>> work) Produce records in a Pulsar transaction, by processing the given message exactly-once.default io.smallrye.mutiny.Uni<Void>withTransactionAndAck(Duration txnTimeout, org.eclipse.microprofile.reactive.messaging.Message<?> message, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<Void>> work) Produce records in a Pulsar transaction, by processing the given batch message exactly-once.default io.smallrye.mutiny.Uni<Void>withTransactionAndAck(org.eclipse.microprofile.reactive.messaging.Message<?> message, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<Void>> work) Produce records in a Pulsar transaction, by processing the given batch message exactly-once.
-
Method Details
-
withTransaction
@CheckReturnValue <R> io.smallrye.mutiny.Uni<R> withTransaction(Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<R>> work) Produce records in a Pulsar transaction.The given processing function receives a
TransactionalEmitterfor producing records, and returns aUnithat will provide the result for a successful transaction.If this method is called on a Vert.x context, the processing function is also called on that context. Otherwise, it is called on the sending thread of the producer.
If the processing completes successfully, the producer is flushed and the transaction is committed. If the processing throws an exception, returns a failing
Uni, or marks theTransactionalEmitterfor abort, the transaction is aborted.- Type Parameters:
R- the return type- Parameters:
work- the processing function for producing records.- Returns:
- the
Unirepresenting the result of the transaction. If the transaction completes successfully, it will complete with the item returned from the work function. If the transaction completes with failure, it will fail with the reason. - Throws:
IllegalStateException- if a transaction is already in progress.
-
withTransaction
<R> io.smallrye.mutiny.Uni<R> withTransaction(Duration txnTimeout, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<R>> work) Produce records in a Pulsar transaction.The given processing function receives a
TransactionalEmitterfor producing records, and returns aUnithat will provide the result for a successful transaction.If this method is called on a Vert.x context, the processing function is also called on that context. Otherwise, it is called on the sending thread of the producer.
If the processing completes successfully, the producer is flushed and the transaction is committed. If the processing throws an exception, returns a failing
Uni, or marks theTransactionalEmitterfor abort, the transaction is aborted.- Type Parameters:
R- the return type- Parameters:
txnTimeout- the timeout of the transactionwork- the processing function for producing records.- Returns:
- the
Unirepresenting the result of the transaction. If the transaction completes successfully, it will complete with the item returned from the work function. If the transaction completes with failure, it will fail with the reason.
-
withTransaction
@CheckReturnValue <R> io.smallrye.mutiny.Uni<R> withTransaction(org.eclipse.microprofile.reactive.messaging.Message<?> message, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<R>> work) Produce records in a Pulsar transaction, by processing the given message exactly-once.If the processing completes successfully, before committing the transaction, the topic partition offsets of the given message will be committed to the transaction. If the processing needs to abort, after aborting the transaction, the consumer's position is reset to the last committed offset, effectively resuming the consumption from that offset.
- Parameters:
message- the incoming Pulsar message.work- the processing function for producing records.- Returns:
- the
Unirepresenting the result of the transaction. If the transaction completes successfully, it will complete with the item returned from the work function. If the transaction completes with failure, it will fail with the reason. - Throws:
IllegalStateException- if a transaction is already in progress.
-
withTransaction
<R> io.smallrye.mutiny.Uni<R> withTransaction(Duration txnTimeout, org.eclipse.microprofile.reactive.messaging.Message<?> message, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<R>> work) Produce records in a Pulsar transaction, by processing the given message exactly-once.If the processing completes successfully, before committing the transaction, the topic partition offsets of the given message will be committed to the transaction. If the processing needs to abort, after aborting the transaction, the consumer's position is reset to the last committed offset, effectively resuming the consumption from that offset.
- Type Parameters:
R- type of the return- Parameters:
txnTimeout- the timeout of the transactionmessage- the incoming Pulsar message.work- function for producing records.- Returns:
- the
Unirepresenting the result of the transaction. If the transaction completes successfully, it will complete with the item returned from the work function. If the transaction completes with failure, it will fail with the reason.
-
withTransactionAndAck
@CheckReturnValue default io.smallrye.mutiny.Uni<Void> withTransactionAndAck(org.eclipse.microprofile.reactive.messaging.Message<?> message, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<Void>> work) Produce records in a Pulsar transaction, by processing the given batch message exactly-once. This is a convenience method that ignores the item returned by the transaction and returns theUniwhich- acks the given message if the transaction is successful.
- nacks the given message if the transaction is aborted.
- Parameters:
message- the incoming Pulsar message.work- function for producing records.- Returns:
- the
Uniacking or negative acking the message depending on the result of the transaction. - Throws:
IllegalStateException- if a transaction is already in progress.- See Also:
-
withTransactionAndAck
@CheckReturnValue default io.smallrye.mutiny.Uni<Void> withTransactionAndAck(Duration txnTimeout, org.eclipse.microprofile.reactive.messaging.Message<?> message, Function<TransactionalEmitter<T>, io.smallrye.mutiny.Uni<Void>> work) Produce records in a Pulsar transaction, by processing the given batch message exactly-once. This is a convenience method that ignores the item returned by the transaction and returns theUniwhich- acks the given message if the transaction is successful.
- nacks the given message if the transaction is aborted.
- Parameters:
txnTimeout- the timeout of the transactionmessage- the incoming Pulsar message.work- function for producing records.- Returns:
- the
Uniacking or negative acking the message depending on the result of the transaction.
-
send
<M extends org.eclipse.microprofile.reactive.messaging.Message<? extends T>> void send(TransactionalEmitter<?> emitter, M msg) Send message to an already started transaction- Type Parameters:
M- the type of the message to send- Parameters:
emitter- the emitter which holds the transactionmsg- the message to send
-
send
Send message to an already started transaction- Parameters:
emitter- the emitter which holds the transactionpayload- the payload to send
-
isTransactionInProgress
boolean isTransactionInProgress()- Returns:
trueif a transaction is in progress.
-