-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Resolves #1519 An empty `@SendTo` on a `@KafkaListener` method means send the reply to the `KafkaHeaders.REPLY_TOPIC` header. This default was not applied for class-level `@KafkaListener`s. **backport to 2.4.x, 2.3.x, 2.2.x** (I will do the back ports, because I expect conflicts).
- Loading branch information
1 parent
724ac8a
commit c52d736
Showing
4 changed files
with
103 additions
and
16 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
spring-kafka/src/main/java/org/springframework/kafka/listener/adapter/AdapterUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2020 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.kafka.listener.adapter; | ||
|
||
import org.springframework.expression.ParserContext; | ||
import org.springframework.expression.common.TemplateParserContext; | ||
import org.springframework.kafka.support.KafkaHeaders; | ||
|
||
/** | ||
* Utilities for listener adapters. | ||
* | ||
* @author Gary Russell | ||
* @since 2.3.13 | ||
* | ||
*/ | ||
public final class AdapterUtils { | ||
|
||
/** | ||
* Parser context for runtime SpEL using ! as the template prefix. | ||
* @since 2.3.13 | ||
*/ | ||
public static final ParserContext PARSER_CONTEXT = new TemplateParserContext("!{", "}"); | ||
|
||
private AdapterUtils() { | ||
} | ||
|
||
/** | ||
* Return the default expression when no SendTo value is present. | ||
* @return the expression. | ||
* @since 2.3.13 | ||
*/ | ||
public static String getDefaultReplyTopicExpression() { | ||
return PARSER_CONTEXT.getExpressionPrefix() + "source.headers['" | ||
+ KafkaHeaders.REPLY_TOPIC + "']" + PARSER_CONTEXT.getExpressionSuffix(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters