![](/img/trans.png)
[英]Configuring a thread pool for Spring Boot asynchronous TaskExecutors?
[英]Configuring thread pool profile in spring boot camel application
我們正在對我們的一個應用程序進行現代化改造,我們決定將 Spring Boot 與 Apache Camel 一起使用。
舊版本的配置文件之一是這樣的:
<camel:threadPoolProfile id="myThreadPoolProfile"
poolSize="10" maxPoolSize="20" maxQueueSize="1000" rejectedPolicy="DiscardOldest" />
我在此鏈接的駱駝文檔中看到的是,可以配置與舊版本基本相同的內容。 但后來我陷入了id
領域。 它丟失了,但有一個屬性camel.threadpool.config
,它的解釋聽起來是我需要的(為特定線程池配置文件添加配置(繼承默認值)),但到目前為止我正在努力使用它。 我試過這樣的事情:
camel:
threadpool:
pool-size: 10
max-pool-size: 20
max-queue-size: 1000
rejected-policy: discardoldest
config:
id: "myThreadPoolProfile"
我收到以下錯誤:
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]
我想我不明白這個 spring 引導配置是如何工作的。
好的,我找到了答案,或者最好在這里說一下例子。 所以我試圖做的語法如下:
camel:
threadpool:
pool-size: 10
max-pool-size: 20
max-queue-size: 1000
rejected-policy: discardoldest
config[myThreadPoolProfile]:
id: "myThreadPoolProfile"
如果您仔細注意到嘗試將 String 映射到 Properties(Map) 的錯誤。
見下文,配置圖中沒有這樣的屬性,因此它失敗了。
我還詳細檢查了同一類的最新 javadoc。 您可以參考相同的內容來檢查所有字段都可用的內容。
以下是 Spring Boot Camel starter 中的可用屬性。
https://camel.apache.org/camel-spring-boot/latest/spring-boot.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.