-
Notifications
You must be signed in to change notification settings - Fork 1.6k
The settings of the properties field have the same problem, and SpEL expressions cannot solve it #1880
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
Comments
I'm sorry what is the problem? Can you be, please, more specific? Thank you for understanding! |
Sorry, let me show you a demo
with application.yml
properties cannot be processed normally like topics,I noticed that the processing of properties in the source code is not the same as topics |
Unlike the other properties that support SpEL, there is no mention of /**
* Kafka consumer properties; they will supersede any properties with the same name
* defined in the consumer factory (if the consumer factory supports property overrides).
* <p>
* <b>Supported Syntax</b>
* <p>The supported syntax for key-value pairs is the same as the
* syntax defined for entries in a Java
* {@linkplain java.util.Properties#load(java.io.Reader) properties file}:
* <ul>
* <li>{@code key=value}</li>
* <li>{@code key:value}</li>
* <li>{@code key value}</li>
* </ul>
* {@code group.id} and {@code client.id} are ignored.
* @return the properties.
* @since 2.2.4
* @see org.apache.kafka.clients.consumer.ConsumerConfig
* @see #groupId()
* @see #clientIdPrefix()
*/
String[] properties() default {}; Vs /**
* The topics for this listener.
* The entries can be 'topic name', 'property-placeholder keys' or 'expressions'.
* An expression must be resolved to the topic name.
* This uses group management and Kafka will assign partitions to group members.
* <p>
* Mutually exclusive with {@link #topicPattern()} and {@link #topicPartitions()}.
* @return the topic names or expressions (SpEL) to listen to.
*/
String[] topics() default {}; This would be a new feature. |
Thanks @garyrussell , This is how I deal with it now
with
It works, but the configuration looks a little cumbersome |
Understood; this is a reasonable new feature request. |
@linchutao I have implemented the change, but FYI, this works with current versions: application.properties: some.prop=max.poll.records: 10\nfetch.min.bytes: 123456 or some.prop=max.poll.records: 10\n \
fetch.min.bytes: 123456 @KafkaListener(id = "kgh1880", topics = "kgh1880", autoStartup = "false",
properties = "${some.prop}") i.e. insert a newline between properties |
application.yml some:
prop: |
max.poll.records: 10
fetch.min.bytes: 123456 |
Resolves spring-projects#1880 SpEL can resolve to `String`, `String[]` or `Collection<String>`.
Resolves #1880 SpEL can resolve to `String`, `String[]` or `Collection<String>`.
Thanks @garyrussell , It looks much more comfortable. |
Affects Version(s): <Spring for Apache Kafka version>
The text was updated successfully, but these errors were encountered: