Skip to content

GH-3661: Resolve Spring Apache Kafka Deprecations #3751

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
Mar 16, 2022

Conversation

garyrussell
Copy link
Contributor

Resolves #3661

Copy link
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

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

Thank you for the doc fix.
Amazing!

Don't we need to mention anything in the "What's New" ?

import org.springframework.retry.support.RetryTemplate;

/**
* @author Gary Russell
Copy link
Member

Choose a reason for hiding this comment

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

Any general JavaDoc, please?

containerProperties.setMessageListener(kafkaListener);
Object existing = containerProperties.getMessageListener();
if (existing != null) {
logger.warn(() -> "Container's existing message listener ("
Copy link
Member

Choose a reason for hiding this comment

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

Can't we throw an IllegalArgumentException instead to signal that provided listener is wrong?
I just try to avoid questions why their listener is out of use...

doWithRetry(template, KafkaInboundGateway.this.recoveryCallback, record, acknowledgment, consumer,
() -> {
Message<?> toSend = enhanceHeaders(message, record, acknowledgment, consumer);
if (toSend != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need to do anything in the else? Like exception or though...
Might be some questions like "where is my message?!"

This might be an existing logic though, therefore I won't mind if we revise it in the separate issue/PR...

Copy link
Contributor Author

@garyrussell garyrussell Mar 16, 2022

Choose a reason for hiding this comment

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

Turns out the try/catch in enhanceHeaders is not necessary - artifact of refactoring; will fix.

if (errorChannel != null) {
KafkaInboundGateway.this.messagingTemplate.send(errorChannel, buildErrorMessage(null,
new ConversionException("Failed to convert to message", record, ex)));
return null;
Copy link
Member

Choose a reason for hiding this comment

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

However this may cover us.
Please, confirm that this is an intention for the missed else I mention before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment above.

private void doSendAndReceive(Message<?> message) {
try {
Message<?> reply = sendAndReceiveMessage(message);
if (reply != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we do anything over here when really no reply?

@@ -152,7 +152,7 @@ private static void registerBean(String beanName, Object bean, BeanFactory beanF
"beanFactory must be an instance of GenericApplicationContext");
GenericApplicationContext applicationContext = (GenericApplicationContext) beanFactory;

applicationContext.registerBean(beanName, (Class<Object>) bean.getClass(), () -> bean);
// applicationContext.registerBean(beanName, (Class<Object>) bean.getClass(), () -> bean);
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why this is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bogus - I am having some problem with Eclipse and this code.

@artembilan artembilan merged commit 0550380 into spring-projects:main Mar 16, 2022
@garyrussell garyrussell deleted the GH-3661 branch September 21, 2022 19:56
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.

Resolve deprecations in spring-integration-kafka after upgrade to Spring for Apache Kafka 2.8/30
2 participants