Configuring thread pool profile in spring boot camel application

3.4k Views Asked by At

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.

2

There are 2 best solutions below

1
On

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.

https://javadoc.io/doc/org.apache.camel.springboot/camel-spring-boot/latest/org/apache/camel/spring/boot/threadpool/CamelThreadPoolConfigurationProperties.ThreadPoolProfileConfigurationProperties.html

Below are the available properties in spring boot camel starter.

https://camel.apache.org/camel-spring-boot/latest/spring-boot.html

0
On

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"