Skip to content

GH-2554: Fix DEFAULT_SCHEDULER_WRAPPER_BEAN_NAME value #2555

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

Merged
merged 3 commits into from
Jan 23, 2023

Conversation

cenkakin
Copy link
Contributor

Fixes #2554.

@DirtiesContext
@EmbeddedKafka(topics = {RetryTopicMultipleListenerIntegrationTests.FIRST_TOPIC,
RetryTopicMultipleListenerIntegrationTests.SECOND_TOPIC}, partitions = 1)
public class RetryTopicMultipleListenerIntegrationTests {
Copy link
Contributor Author

@cenkakin cenkakin Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got mainly inspired by this test. Instead of adding a new test class, I can modify that class to make it cover this case or keep it as a separate class like in the PR. Or I can delete the test if you don't think it is worthwhile. Whatever you like.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cenkakin !

Not sure why do we need such a complex integration test just to verify that there is no conflict around defaultRetryTopicKafkaTemplate bean...
Right, I see that we need a second @RetryableTopic to make it fail after gac.registerBean(RetryTopicBeanNames.DEFAULT_SCHEDULER_WRAPPER_BEAN_NAME,, but probably we indeed can cover this use-case just adding extra config into that RetryTopicSameContainerFactoryIntegrationTests you mention before.

WDYT?

Thank you for contribution!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it is what I can do. But we need to modify Config class in RetryTopicSameContainerFactoryIntegrationTests more to trigger the line that fails.

As far as I understand from the test case intended to cover, it should be ok. Let me push another commit.

@DirtiesContext
@EmbeddedKafka(topics = {RetryTopicMultipleListenerIntegrationTests.FIRST_TOPIC,
RetryTopicMultipleListenerIntegrationTests.SECOND_TOPIC}, partitions = 1)
public class RetryTopicMultipleListenerIntegrationTests {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cenkakin !

Not sure why do we need such a complex integration test just to verify that there is no conflict around defaultRetryTopicKafkaTemplate bean...
Right, I see that we need a second @RetryableTopic to make it fail after gac.registerBean(RetryTopicBeanNames.DEFAULT_SCHEDULER_WRAPPER_BEAN_NAME,, but probably we indeed can cover this use-case just adding extra config into that RetryTopicSameContainerFactoryIntegrationTests you mention before.

WDYT?

Thank you for contribution!

}

@EnableKafka
@Configuration
static class Config extends RetryTopicConfigurationSupport {
static class Config {
Copy link
Contributor Author

@cenkakin cenkakin Jan 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't extend RetryTopicConfigurationSupport and shouldn't inject our own ThreadPoolTaskScheduler ->
https://github.com/spring-projects/spring-kafka/pull/2555/files#diff-80d8fe2567e6640c6d1edada33ec0bf783012606c2264cf4fc6b3aed4cca9742L242

Comment on lines 189 to 192
DefaultErrorHandler errorHandler = new DefaultErrorHandler(
(cr, ex) -> latchContainer.countDownLatch2.countDown(),
new FixedBackOff(0, 2));
factory.setCommonErrorHandler(errorHandler);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part we no longer cover anymore.

I just pushed another commit that creates a new bean and keeps BasicKafkaListener instead of modifying it:

01f0d6d

@cenkakin
Copy link
Contributor Author

cenkakin commented Jan 23, 2023

Hey @artembilan! Thank you for the feedback! I pushed commits and left comments. Basically, the following three commits present different approaches:

  • e4827ec: Completely separate integration test
  • e88fb49: Modify RetryTopicSameContainerFactoryIntegrationTests, replace basicKafkaListener with another retryableListener
  • e88fb49: Modify RetryTopicSameContainerFactoryIntegrationTests, add another retryableListener and keep basicKafkaListener

I would vote for the PR's current status (3rd approach). Please let me know your thoughts, and I will update the PR accordingly.

@artembilan artembilan merged commit 9c22868 into spring-projects:main Jan 23, 2023
@artembilan
Copy link
Member

Sorry, @garyrussell , some glitch has happened over here on GH, so I pressed Rebase & merge accidentally without squashing.
Next time will pull locally for more control 😄

@cenkakin , thank you for contribution; looking forward for more!

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

Successfully merging this pull request may close these issues.

An application using default spring boot configuration fails at the startup when there are multiple @KafkaListener with @RetryableTopic
2 participants