Container-Managed Process Engine custom configuration

Hi! How can I add configuration as ProcessEngineConfiguration class to my container managed process engine using spring?

I defined a process engine as follow:

<process-engine name="processEngine">
    <datasource>java:jboss/datasources/ProcessEngine</datasource>
     <configuration>...CustomProcessEngineConfiguration</configuration>
    ...
</process-engine>

So it doesn’t work…How can I add some configuration to my container managed process engine configuration?

Thanks in advance

Hi @devj87,

you can find the right way of how to use your custom process engine configuration using the Spring XML in our documentation.

If you need any further help, do not hesitate to ask more questions. Hope that helps.

Best,
Johannes

Thanks for reply @JoHeinem I defined process engine within my application context as rg.springframework.jndi.JndiObjectFactoryBean :

  <bean name="processEngine" id="processEngine"
    class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName"
        value="java:global/camunda-bpm-platform/process-engine/processEngine" />
</bean>

So how can I add process engine configuration to this kind of creation?
For example I need to add IdGenerator as the camunda provided or as a custom

I tried to add a processEngineConfiguration bean to processEngine but it doesn’t work.

How can I solve?

Best regards

Hi @devj87,

In general, your approach is the right way to use a custom engine configuration. However, it is hard to tell what exactly the problem is. So could you please clarify your problem by posting the error output (e.g. log) or describing in detail what exactly doesn’t work?

However, I have two hints that might help to solve the issue:

  • Is your class JndiOjbectFactoryBean extending the abstract class ProcessEngineConfiguration? Maybe you can have a look at our default implementation on how we configure the engine by default.
  • The XML code you posted, should be contained in the camunda.cfg.xml. Is that already the case?

Best,
Johannes

Thanks @JoHeinem, my objective is add Id Generator to my container managed process engine so I followed this guide
https://docs.camunda.org/manual/7.4/user-guide/runtime-container-integration/jboss/

So I need to add a configuration which include IdGenerator settings to my process engine definition within wildfly’s standalone.xml

As show blow:

<process-engine name="default" default="true">
    <datasource>java:jboss/datasources/ProcessEngine</datasource>
    **<configuration>org.my.custom.ProcessEngineConfiguration</configuration>**
    <history-level>full</history-level>
    <properties>
    <property name="myCustomProperty">true</property>
    <property name="lockTimeInMillis">300000</property>
    <property name="waitTimeInMillis">5000</property>
    </properties>
</process-engine>

So how can I provide a custom configuration?
Is there a sample class?

Hi @devj87,

Sorry for the misguidance. I totally forgot to ask you about your camunda version. In jboss you need of course to edit wildfly’s standalone.xml.

Basically, what you provide in the < configuration> tag is a path and name of a java class that extends the abstract class ProcessEngineConfiguration . In the ‘camunda-bpm-platform/engine/src/main/java/org/camunda/bpm/engine/impl/cfg/’ directory you can already find some sample/default implementations (see e.g. here). Within the tag you then provide the path beginning from the ‘org’ directory to the file and the name of the file (concatenated with dots). For you example you could try out following sample configuration:

  <configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration>

The property tags then allow you to change the properties without touching any java code.

Does that work for you? If not, could you please provide some error logs?

Best,
Johannes

@JoHeinem I’m using 7.5 version.

So If I only want to set IdGenerator for my container managed process engine
I need to define:

<configuration>org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration</configuration> 

Is the same solution for a container managed configuration?

@devj87 Yes, it is. Keep in mind though, that it is not enough to just use the StandaloneProcessEngineConfiguration, because the standalone.xml just allows you to define String, Integer and Boolean values (see here). So if you want to use your own IdGenerator you have two options:

  • You create your own config class (MyProcessEngineConfiguration) that extends ProcessEngineConfiguration and then plug that in your standalone.xml (meaning put that inside you < configuration> tag
  • You configure your IdGenerator as a plugin and add that to your standalone.xml (see here on how to do that).

Best,
Johannes

Hi @JoHeinem I tried to create my custom process engine configuration extending ProcessEngineConfigurationImpl as below:

  @Configuration
  public class CustomProcessEngineConfiguration extends ProcessEngineConfigurationImpl{
    @Autowired
    protected CustomIdGenerator customIdGenerator; 
    
    @Override
    public ProcessEngineConfigurationImpl setIdGenerator(IdGenerator customIdGenerator) {
      return super.setIdGenerator(customIdGenerator);
    }
  
    @Override
    protected Collection<? extends CommandInterceptor> getDefaultCommandInterceptorsTxRequired() {
      // TODO Auto-generated method stub
      return getDefaultCommandInterceptorsTxRequired();
    }
  
    @Override
    protected Collection<? extends CommandInterceptor> getDefaultCommandInterceptorsTxRequiresNew() {
      // TODO Auto-generated method stub
      return getDefaultCommandInterceptorsTxRequiresNew();
    }          
  }

Assuming is correct how can I add it to my engine configuration?

I tried to insert class fqn for tag in standalone.xml but It return ClassNotFound Exception.

So is there a way to add configuration to my process engine spring bean?
Can you post an example as process engine jndi spring bean, please?

Hi @devj87,

According to the docs you have to extend the JtaProcessEngineConfiguration for your custom configuration implementation. So try to change that and have a look if that already solves the problem.

In case that didn’t help, you should check if you adapted the following line in the standalone.xml :

<bean id="processEngineConfiguration" class="org.my.company.CustomProcessEngineConfiguration">

Where org.my.company is supposed be replaced with the package name, where you custom configuration is located.

If that still didn’t help, could you please post the stacktrace and your new standalone.xml once again?

Cheers,
Johannes

Hi @devj87,

I took a deeper look into your problem and it’s not as easy to solve as I thought. On a general note first: you cannot inject spring into Wildfly as this is not supported by Wildfly’s core system. You have to create an own wildfly module and add that to the subsystem. Thus, the best way to use your own id generator in Camunda Wildfly is:

  1. Create a Wildfly module with a custom ProcessEnginePlugin. See here for how to create a process engine plugin and here an example on how to create a Wildfly module. In addition, the
    custom ID generator needs the following module dependencies:
  • camunda-engine
  • whatever is needed for your custom id generator
  1. Register the custom module as a module dependency in Camunda Wildfly subsystem.

  2. Register the ProcessEnginePlugin for the process engine in the standalone.xml (see here).

Hope that helps :slight_smile:

Best,
Johannes