Class PulsarTransactionManager
java.lang.Object
org.springframework.transaction.support.AbstractPlatformTransactionManager
org.springframework.pulsar.transaction.PulsarTransactionManager
- All Implemented Interfaces:
Serializable,PulsarAwareTransactionManager,org.springframework.transaction.ConfigurableTransactionManager,org.springframework.transaction.PlatformTransactionManager,org.springframework.transaction.TransactionManager
public class PulsarTransactionManager
extends org.springframework.transaction.support.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
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.transaction.support.AbstractPlatformTransactionManager
org.springframework.transaction.support.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 voidprotected voiddoCleanupAfterCompletion(Object transaction) protected voiddoCommit(org.springframework.transaction.support.DefaultTransactionStatus status) protected Objectprotected voidprotected voiddoRollback(org.springframework.transaction.support.DefaultTransactionStatus status) protected voiddoSetRollbackOnly(org.springframework.transaction.support.DefaultTransactionStatus status) protected 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 classorg.springframework.transaction.support.AbstractPlatformTransactionManager
-
isExistingTransaction
- Overrides:
isExistingTransactionin classorg.springframework.transaction.support.AbstractPlatformTransactionManager
-
doBegin
protected void doBegin(Object transaction, org.springframework.transaction.TransactionDefinition definition) - Specified by:
doBeginin classorg.springframework.transaction.support.AbstractPlatformTransactionManager
-
doSuspend
- Overrides:
doSuspendin classorg.springframework.transaction.support.AbstractPlatformTransactionManager
-
doResume
- Overrides:
doResumein classorg.springframework.transaction.support.AbstractPlatformTransactionManager
-
doCommit
protected void doCommit(org.springframework.transaction.support.DefaultTransactionStatus status) - Specified by:
doCommitin classorg.springframework.transaction.support.AbstractPlatformTransactionManager
-
doRollback
protected void doRollback(org.springframework.transaction.support.DefaultTransactionStatus status) - Specified by:
doRollbackin classorg.springframework.transaction.support.AbstractPlatformTransactionManager
-
doSetRollbackOnly
protected void doSetRollbackOnly(org.springframework.transaction.support.DefaultTransactionStatus status) - Overrides:
doSetRollbackOnlyin classorg.springframework.transaction.support.AbstractPlatformTransactionManager
-
doCleanupAfterCompletion
- Overrides:
doCleanupAfterCompletionin classorg.springframework.transaction.support.AbstractPlatformTransactionManager
-