Class PulsarTransactionManager
java.lang.Object
org.springframework.transaction.support.AbstractPlatformTransactionManager
org.springframework.pulsar.transaction.PulsarTransactionManager
- All Implemented Interfaces:
Serializable,PulsarAwareTransactionManager,ConfigurableTransactionManager,PlatformTransactionManager,TransactionManager
public class PulsarTransactionManager
extends AbstractPlatformTransactionManager
implements PulsarAwareTransactionManager
Binds a
native Pulsar transaction from the specified
PulsarClient to the current thread, allowing for one transaction per thread per
Pulsar client.
This transaction manager is not able to provide XA transactions, for example in order to share transactions between messaging and database access.
Application code is required to retrieve the transactional Pulsar resources via
PulsarTransactionUtils.obtainResourceHolder(org.apache.pulsar.client.api.PulsarClient, java.time.Duration). The PulsarTemplate will
auto-detect a thread-bound transaction and automatically participate in it.
Transaction synchronization is turned off by default, as this manager might be used
alongside a datastore-based Spring transaction manager such as the JDBC
DataSourceTransactionManager, which has stronger needs for synchronization.
- Since:
- 1.1.0
- Author:
- Chris Bono
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
AbstractPlatformTransactionManager.SuspendedResourcesHolder -
Field Summary
Fields inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
logger, SYNCHRONIZATION_ALWAYS, SYNCHRONIZATION_NEVER, SYNCHRONIZATION_ON_ACTUAL_TRANSACTION -
Constructor Summary
ConstructorsConstructorDescriptionPulsarTransactionManager(org.apache.pulsar.client.api.PulsarClient pulsarClient) Create a new transaction manager. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoBegin(Object transaction, TransactionDefinition definition) protected voiddoCleanupAfterCompletion(Object transaction) protected voiddoCommit(DefaultTransactionStatus status) protected Objectprotected voidprotected voiddoRollback(DefaultTransactionStatus status) protected voidprotected Objectorg.apache.pulsar.client.api.PulsarClientGet the Pulsar client.protected booleanisExistingTransaction(Object transaction) Methods inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
commit, determineTimeout, getDefaultTimeout, getTransaction, getTransactionExecutionListeners, getTransactionSynchronization, invokeAfterCompletion, isFailEarlyOnGlobalRollbackOnly, isGlobalRollbackOnParticipationFailure, isNestedTransactionAllowed, isRollbackOnCommitFailure, isValidateExistingTransaction, prepareForCommit, prepareSynchronization, registerAfterCompletionWithExistingTransaction, resume, rollback, setDefaultTimeout, setFailEarlyOnGlobalRollbackOnly, setGlobalRollbackOnParticipationFailure, setNestedTransactionAllowed, setRollbackOnCommitFailure, setTransactionExecutionListeners, setTransactionSynchronization, setTransactionSynchronizationName, setValidateExistingTransaction, shouldCommitOnGlobalRollbackOnly, suspend, triggerBeforeCommit, triggerBeforeCompletion, useSavepointForNestedTransactionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.transaction.ConfigurableTransactionManager
addListenerMethods inherited from interface org.springframework.transaction.PlatformTransactionManager
commit, getTransaction, rollback
-
Constructor Details
-
PulsarTransactionManager
public PulsarTransactionManager(org.apache.pulsar.client.api.PulsarClient pulsarClient) Create a new transaction manager.- Parameters:
pulsarClient- the pulsar client used to construct the backing Pulsar native transactions.
-
-
Method Details
-
getPulsarClient
public org.apache.pulsar.client.api.PulsarClient getPulsarClient()Description copied from interface:PulsarAwareTransactionManagerGet the Pulsar client.- Specified by:
getPulsarClientin interfacePulsarAwareTransactionManager- Returns:
- the Pulsar client
-
doGetTransaction
- Specified by:
doGetTransactionin classAbstractPlatformTransactionManager
-
isExistingTransaction
- Overrides:
isExistingTransactionin classAbstractPlatformTransactionManager
-
doBegin
- Specified by:
doBeginin classAbstractPlatformTransactionManager
-
doSuspend
- Overrides:
doSuspendin classAbstractPlatformTransactionManager
-
doResume
- Overrides:
doResumein classAbstractPlatformTransactionManager
-
doCommit
- Specified by:
doCommitin classAbstractPlatformTransactionManager
-
doRollback
- Specified by:
doRollbackin classAbstractPlatformTransactionManager
-
doSetRollbackOnly
- Overrides:
doSetRollbackOnlyin classAbstractPlatformTransactionManager
-
doCleanupAfterCompletion
- Overrides:
doCleanupAfterCompletionin classAbstractPlatformTransactionManager
-