Thorntail: dynamic values on project_defaults.yml

11/23/2020

Working with Thorntail/Kubernetes, is it possible to use dynamic values on project_defaults.yml? For example:

thorntail:
  ejb3:
    thread-pools:
      default:
        max-threads: ${my.variable}

Where my.variable will be configured on the dashboard of a specific module.

The idea is to replace standalone.xml values without performing a new deploy every time I need to change the value.

-- Cássio
kubernetes
thorntail

2 Answers

11/26/2020

That is in theory possible, because Thorntail is based on WildFly, which allows changing some configuration values without restart. Your example refers to a WildFly configuration value, so it might be possible. Those configuration values in Thorntail that don't come from WildFly don't allow for this at all.

You can use the management fraction to let Thorntail expose the WildFly management interface. Then, you can use the WildFly management client (ModelControllerClient) to issue management operations. However, I'd discourage you from doing this, as Thorntail isn't really designed for it.

(Also, Thorntail has reached its end of life. See here for more: https://thorntail.io/posts/the-end-of-an-era/)

-- Ladicek
Source: StackOverflow

12/10/2020

We can do that by configuring the variable as an environment variable. Using the previous example:

thorntail:
  ejb3:
    thread-pools:
      default:
        max-threads: ${env.my_variable:default_value}

And then we configure my_variable on the dashboard of the desired module.

It is important to notice that we should define a default value, because if that thorntail property is numeric and the environment variable is not defined on the module, we will face a parsing problem since the parser will interpret the variable name as a number. This is a real example:

Kubernets module:

RCNT_MAX_THREADS is defined with 12

project_defaults.yml:

thorntail:
  ejb3:
    thread-pools:
      default:
        max-threads: ${env.RCNT_MAX_THREADS:10}

This will cause the application to use max-threads with the value 12. If we don't define RCNT_MAX_THREADS on the module, the value 10 will be used instead.

There is also a very useful option to track what values are really being used: https://docs.thorntail.io/2.5.0.Final/#the-usage-txt-file_thorntail

-- Cássio
Source: StackOverflow