Skip to content

Deprecated ContainerProperties#setTransactionDefinition #1888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
orange-buffalo opened this issue Jul 27, 2021 · 2 comments · Fixed by #1889
Closed

Deprecated ContainerProperties#setTransactionDefinition #1888

orange-buffalo opened this issue Jul 27, 2021 · 2 comments · Fixed by #1889

Comments

@orange-buffalo
Copy link

In scope of #1699, ContainerProperties#setTransactionDefinition was deprecated together with ChainedTransactionManager. The note to this method, which we believe caused the deprecation, states:

Note that this is only generally useful when used with a org.springframework.kafka.transaction.ChainedKafkaTransactionManager configured with a non-Kafka transaction manager.

However, we do not use ChainedTransactionManager and do use ContainerProperties#setTransactionDefinition. Our use-case is implementation of Idempotent Consumer pattern with database storage for processed messages. The rough solution is as following:

  • Set JDBC/JPA Transaction Manager as ContainerProperties#setTransactionManager - database transaction is open by container when a new record is processed.
  • Implement RecordFilterStrategy that stores the incoming message id in the database, and filters the record if this id is already present.
  • This way, @KafkaListener and RecordFilterStrategy are executed in the same database transaction, which guarantees atomic write of business data and Idempotent Consumer records.

Since our @KafkaListeners have different requirements to the database transactions (in particular, timeouts), we use ContainerProperties#setTransactionDefinition to configure those. In case this method is removed after deprecation, we are in big trouble.

Would it be possible to remove the deprecation and update the javadocs of this method, so our services continue to function properly with future updates of spring-kafka?

@garyrussell garyrussell self-assigned this Jul 27, 2021
@garyrussell
Copy link
Contributor

Yes; your use case makes sense.

@garyrussell garyrussell added this to the 2.8.0-M2 milestone Jul 27, 2021
garyrussell added a commit to garyrussell/spring-kafka that referenced this issue Jul 27, 2021
Resolves: spring-projects#1888

Incorrectly deprecated when ChainedKafkaTransactionManager was deprecated.

There are still valid use cases for this property.
artembilan pushed a commit that referenced this issue Jul 27, 2021
Resolves: #1888

Incorrectly deprecated when ChainedKafkaTransactionManager was deprecated.

There are still valid use cases for this property.
artembilan pushed a commit that referenced this issue Jul 27, 2021
Resolves: #1888

Incorrectly deprecated when ChainedKafkaTransactionManager was deprecated.

There are still valid use cases for this property.
@orange-buffalo
Copy link
Author

Beautiful, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants