AppEngine programmatic linking to ProcessEngine

I have a spring application (not boot) that uses java config for the process engine, but also hosts the rest api for the modeler webapp to deploy app definitions. Now with the new AppEngine I needed to deploy the app engine rest services in my application. This works fine, but it only deploys to the act_app tables if not linked to the process engine, which I don’t know how to do.

    @Bean
    public ProcessEngineConfiguration processEngineConfiguration(DataSource dataSource, PlatformTransactionManager transactionManager) {
        SpringProcessEngineConfiguration config = new SpringProcessEngineConfiguration();
        config.setDataSource(dataSource);
        config.setTransactionManager(transactionManager);
        ... some more config

        // configurators
        ArrayList<EngineConfigurator> configurators = new ArrayList<>(2);
        configurators.add(new SpringFormEngineConfigurator());
        configurators.add(new SpringContentEngineConfigurator());
        config.setConfigurators(configurators);
        
        ... some more config like parse handlers
        return config;
    }

    @Bean
    public ProcessEngine processEngine(ProcessEngineConfiguration config) {
        return config.buildProcessEngine();
    }

So the above configures the process engine, and adding the configurators also hooks up the Form and Content engines.

There is however no SpringAppEngineConfigurator to add to the configurators.

   @Bean
    public AppEngineConfiguration appEngineConfiguration(ProcessEngine processEngine, ProcessEngineConfiguration processEngineConfiguration, DataSource dataSource, PlatformTransactionManager transactionManager) {
        SpringAppEngineConfiguration appEngineConfiguration = new SpringAppEngineConfiguration();
        appEngineConfiguration.setDataSource(dataSource);
        appEngineConfiguration.setDatabaseSchemaUpdate(AppEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
        appEngineConfiguration.setTransactionManager(transactionManager);
        appEngineConfiguration.setDisableIdmEngine(true);
        // THIS AT LEAST DEPLOYS TO FORM ENGINE
        appEngineConfiguration.setConfigurators(processEngineConfiguration.getConfigurators());

        return appEngineConfiguration;
    }

    @Bean
    public AppEngineFactoryBean appEngineFactoryBean(AppEngineConfiguration appEngineConfiguration) {
        AppEngineFactoryBean factoryBean = new AppEngineFactoryBean();
        factoryBean.setAppEngineConfiguration(appEngineConfiguration);
        return factoryBean;
    }

    @Bean
    public AppEngine appEngine(AppEngineFactoryBean appEngineFactoryBean) {
        try {
            return appEngineFactoryBean.getObject();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

So while I can grab the other configurators from the processEngineConfiguration and it does deploy to the form engine, I can’t get deployment of processes working.

I have also tried: appEngineConfiguration.setCustomPostDeployers(Arrays.asList(new BpmnDeployer()));
But gets NullPointer here: CommandContextUtil.getProcessEngineConfiguration().getRepositoryService();

I don’t understand enough of the guts here to know where to plug it in.

I would advise you to look at the ProcessEngineAutoConfiguration to see how this is done with Spring Boot. More precisely the ProcessEngineAppConfiguration within the auto configuration.

You should not build the process engine like you are doing it when it is standalone. There is a ProcessEngineConfigurator and you need to add that to the AppEngine.

Then in order to expose the ProcessEngine you need to do something like in the ProcessEngineServicesAutoConfiguration more precisely the AlreadyInitializedAppEngineConfiguration.

Thanks. I had a brief look at those classes before I posted, but it will take me a bit of time to understand all the inter-relationships.

Let me phrase it differently…

How would you connect the app engine to a non-spring standalone process engine as here?

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="processEngineConfiguration" class="org.flowable.engine.impl.cfg.StandaloneProcessEngineConfiguration">

    <property name="jdbcUrl" value="jdbc:h2:mem:flowable;DB_CLOSE_DELAY=1000" />
    <property name="jdbcDriver" value="org.h2.Driver" />
    <property name="jdbcUsername" value="sa" />
    <property name="jdbcPassword" value="" />

    <property name="databaseSchemaUpdate" value="true" />

    <property name="asyncExecutorActivate" value="false" />

    <property name="mailServerHost" value="mail.my-corp.com" />
    <property name="mailServerPort" value="5025" />
  </bean>

</beans>

Taken from here: https://www.flowable.org/docs/userguide/index.html#configuration

Thanks. I had a brief look at those classes before I posted, but it will take me a bit of time to understand all the inter-relationships.

The Spring Boot auto configuration would be the same way I would do a non Spring Boot application and a non spring application.

In that XML you will need to create an additional appEngineConfiguration, add a processEngineConfigurator and add it to the appEngineConfiguration. and then use AppEngines to get the AppEngine. This would trigger an initialisation of the ProcessEngine as well

Cheers,
Filip

Hi Filip

Apologies. I should have just read your first answer more carefully as there was enough information to resolve my issue. Took a few minutes to rearrange my configuration.

The AppEngine should be driving the configuration and other configurators added to it.

Thanks a lot!

No problem @ruzkant. I should have been clearer as well. Glad that you resolved your problem.

Yes in this case the AppEngine is the one leading the configurations.

Cheers,
Filip

By the way I found a problem with the app deployment code where version numbers were not increased…

See here: https://github.com/flowable/flowable-engine/pull/1356

Thanks for the PR @ruzkant. Tijs already merged it

1 Like