英文:
Configuring thread pool profile in spring boot camel application
问题
我们正在对我们的一个应用程序进行现代化改造,并决定与Apache Camel一起使用Spring Boot。
旧版本的一个配置文件如下所示:
<camel:threadPoolProfile id="myThreadPoolProfile"
poolSize="10" maxPoolSize="20" maxQueueSize="1000" rejectedPolicy="DiscardOldest" />
我在Camel文档的链接中看到,基本上可以配置与旧版本中相同的内容。但是,我在id
字段上遇到了问题。它不见了,但是有一个属性camel.threadpool.config
,其解释听起来像是我需要的内容(为特定线程池配置添加配置(继承默认值)),但是到目前为止,我很难使用它。我尝试了类似于以下的内容:
camel:
threadpool:
pool-size: 10
max-pool-size: 20
max-queue-size: 1000
rejected-policy: discardoldest
config:
id: "myThreadPoolProfile"
我得到了以下错误:
错误描述:
未能将属性绑定到`camel.threadpool.config.id`下的`org.apache.camel.spring.boot.threadpool.CamelThreadPoolConfigurationProperties$ThreadPoolProfileConfigurationProperties`:
原因:找不到能够从类型`java.lang.String`转换为类型`org.apache.camel.spring.boot.threadpool.CamelThreadPoolConfigurationProperties$ThreadPoolProfileConfigurationProperties`的转换器。
我猜我不太理解这个Spring Boot的配置是如何工作的。
英文:
We are modernizing one of our applications and we decided to use Spring Boot together with Apache Camel.
One of the configuration files from old version has something like this:
<camel:threadPoolProfile id="myThreadPoolProfile"
poolSize="10" maxPoolSize="20" maxQueueSize="1000" rejectedPolicy="DiscardOldest" />
What I saw in camel documentation on this link is that there is possibility to configure basically the same thing we have in old version. But then I got stuck on id
field. It's missing, but there is property camel.threadpool.config
which explanation sounds something I need (Adds a configuration for a specific thread pool profile (inherits default values)), but so far I am struggling to make a use of it. I tried something like this:
camel:
threadpool:
pool-size: 10
max-pool-size: 20
max-queue-size: 1000
rejected-policy: discardoldest
config:
id: "myThreadPoolProfile"
I am getting following error:
Description:
Failed to bind properties under 'camel.threadpool.config.id' to org.apache.camel.spring.boot.threadpool.CamelThreadPoolConfigurationProperties$ThreadPoolProfileConfigurationProperties:
Reason: No converter found capable of converting from type [java.lang.String] to type [org.apache.camel.spring.boot.threadpool.CamelThreadPoolConfigurationProperties$ThreadPoolProfileConfigurationProperties]
I guess I don't understand how this spring boot configuration works.
答案1
得分: 1
我找到了一个答案,或者更准确地说是一个例子在这里。因此,我尝试做的事情的语法将如下所示:
camel:
threadpool:
pool-size: 10
max-pool-size: 20
max-queue-size: 1000
rejected-policy: discardoldest
config[myThreadPoolProfile]:
id: "myThreadPoolProfile"
英文:
Ok I found an answer, or better to say example here. So the syntax for what I was trying to do would be following:
camel:
threadpool:
pool-size: 10
max-pool-size: 20
max-queue-size: 1000
rejected-policy: discardoldest
config[myThreadPoolProfile]:
id: "myThreadPoolProfile"
答案2
得分: 0
如果您仔细注意错误,您会注意到您正在尝试将String映射到Properties(Map)。
请注意,在配置映射中没有此类属性,因此它失败了。
我还详细检查了同一类的最新javadoc。您可以参考同样的内容,以检查所有可用的字段。
以下是Spring Boot Camel Starter中可用的属性。
(链接已省略)
英文:
If you carefully notice the error you are trying to map String to Properties(Map).
See below there is no such property available in configuration map hence its failing.
I have also checked in detail with latest javadoc for the same class. You can refer the same to check what all fields are available.
Below are the available properties in spring boot camel starter.
https://camel.apache.org/camel-spring-boot/latest/spring-boot.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论