Skip to content

Commit 8553c6f

Browse files
garyrussellartembilan
authored andcommitted
GH-1888: Revert Deprec. setTransactionDefinition()
Resolves: #1888 Incorrectly deprecated when ChainedKafkaTransactionManager was deprecated. There are still valid use cases for this property.
1 parent 04e574c commit 8553c6f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/ContainerProperties.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.aop.support.AopUtils;
3333
import org.springframework.core.task.AsyncListenableTaskExecutor;
3434
import org.springframework.kafka.support.TopicPartitionOffset;
35+
import org.springframework.kafka.transaction.KafkaTransactionManager;
3536
import org.springframework.lang.Nullable;
3637
import org.springframework.scheduling.TaskScheduler;
3738
import org.springframework.transaction.PlatformTransactionManager;
@@ -748,16 +749,17 @@ public TransactionDefinition getTransactionDefinition() {
748749
/**
749750
* Set a transaction definition with properties (e.g. timeout) that will be copied to
750751
* the container's transaction template. Note that this is only generally useful when
751-
* used with a
752-
* {@link org.springframework.kafka.transaction.ChainedKafkaTransactionManager}
753-
* configured with a non-Kafka transaction manager. Kafka has no concept of
754-
* transaction timeout, for example.
752+
* used with a {@link #setTransactionManager(PlatformTransactionManager)
753+
* PlatformTransactionManager} that supports a custom definition; this does NOT
754+
* include the {@link KafkaTransactionManager} which has no concept of transaction
755+
* timeout. It can be useful to start, for example a database transaction, in the
756+
* container, rather than using {@code @Transactional} on the listener, because then a
757+
* record interceptor, or filter in a listener adapter can participate in the
758+
* transaction.
755759
* @param transactionDefinition the definition.
756760
* @since 2.5.4
757-
* @deprecated Refer to the
758-
* {@link org.springframework.data.transaction.ChainedTransactionManager} javadocs.
761+
* @see #setTransactionManager(PlatformTransactionManager)
759762
*/
760-
@Deprecated
761763
public void setTransactionDefinition(TransactionDefinition transactionDefinition) {
762764
this.transactionDefinition = transactionDefinition;
763765
}

0 commit comments

Comments
 (0)