Use java static Strings in models

Hi
I would like to user variable names that are declared in a java class, for external task topics for example, like

public static final String TIMEOUT = “timeoutTopic”;

and use this in in the model to avoid problems if we for some reasan want to change that topic name in the future.

I have the strings declared in a bean (wokerProperties) that camunda finds and the question is simply. Is it possible to use it in this way in the model? If so how would the expression look like.

I want to use it in the model like ${workerProperties.TIMEOUT} (this doesnt work by the way… :wink: )
Do I have to declare getMethod to be abe to use it? Like this?

public String getTIMEOUT() {
return TIMEOUT;
}
If I declare the get metod it works to use ${workerProperties.TIMEOUT}) but it is annoying to have to declare get methodes for all the statics. Is it the only/correct way?

Thanks
/Martin

Hi Martin,

Afaik having getters is the way to make it work.

Cheers,
Thorben

1 Like

Ok, thanks. I suspected it might be. A bit clupsy but it will have to do.
Thanks,
/Martin

I noted “use in model” - and “static”.

Not sure it’ll work… Specifically because anything in our model’s in-flight context may not provide necessary “static-like” properties. Meaning, one process instance may not correctly set a new value so that other in-flight instances can read the new setting.

Constraints may include:

  • reconciling an update transaction to pending into dependent process instances (i.e. thinking in terms of Camunda’s persistence layer).
  • managing consistent values between Camunda engine-host platforms.

Per an earlier comment… recommend using a shared service dedicated to configuration and/or property values.