flowable / flowable-engine

A compact and highly efficient workflow and Business Process Management (BPM) platform for developers, system admins and business users.
https://www.flowable.org
Apache License 2.0
7.59k stars 2.54k forks source link

Not possible to exclude the `flowable-event-registry` JAR even if EventRegistry disabled #3907

Open karel-cernohorsky opened 3 weeks ago

karel-cernohorsky commented 3 weeks ago

Describe the bug

Even when disabling the EventRegistry via:

flowable.eventregistry.enabled = false

(see @ConditionalOnEventRegistry and its usage)

and / or via:

@Bean
EngineConfigurationConfigurer<SpringProcessEngineConfiguration> customConfig() {
    return spec -> spec.setDisableEventRegistry(true);
}

it's still not possible to exclude from dependencies the following JAR:

due to a missing check of whether the EventRegistry is disabled in:

https://github.com/flowable/flowable-engine/blob/90b4b509821d3c0ab0051b2be311afbd158da8db/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java#L1683

thus not bypassing the instantiation of:

https://github.com/flowable/flowable-engine/blob/90b4b509821d3c0ab0051b2be311afbd158da8db/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java#L1688

Expected behavior

When the "EventRegistry" is "disabled" (via a property or a java code)
Then it's possible to exclude from dependencies the "flowable-event-registry" JAR 

Most likely via bypassing the instantiation of the BpmnEventRegistryEventConsumer in such a case.

Code

Currently, we are forced to apply a dummy work-around, such as:

@Bean
EngineConfigurationConfigurer<SpringProcessEngineConfiguration> customConfig() {
    return spec -> spec.setDisableEventRegistry(true)
            .setEventRegistryEventConsumer(noopEventRegistryEventConsumer());
}

private static EventRegistryEventConsumer noopEventRegistryEventConsumer() {
    return new EventRegistryEventConsumer() {
        @Override
        public EventRegistryProcessingInfo eventReceived(EventRegistryEvent event) {
            return null;
        }

        @Override
        public String getConsumerKey() {
            return "noopEventConsumer";
        }
    };
}

thus bypassing the instantiation of the BpmnEventRegistryEventConsumer in: https://github.com/flowable/flowable-engine/blob/90b4b509821d3c0ab0051b2be311afbd158da8db/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java#L1683-L1692

For comparison, the IDM engine's inclusion is properly checked in: https://github.com/flowable/flowable-engine/blob/90b4b509821d3c0ab0051b2be311afbd158da8db/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cfg/ProcessEngineConfigurationImpl.java#L1676-L1681

Additional context

Flowable branches:

Spring Boot used in the version declared by the respective Flowable version.

relevant exclusions & dependencies in build.gradle:

configurations.all {
    excludeRules += [
        [ group: 'org.flowable', module: 'flowable-cmmn-model' ],
        [ group: 'org.flowable', module: 'flowable-dmn-model' ],
        [ group: 'org.flowable', module: 'flowable-event-registry' ],
        [ group: 'org.flowable', module: 'flowable-event-registry-configurator' ],
        [ group: 'org.flowable', module: 'flowable-event-registry-model' ],
        [ group: 'org.flowable', module: 'flowable-idm-engine' ],
        [ group: 'org.flowable', module: 'flowable-idm-engine-configurator' ],
        [ group: 'org.yaml', module: 'snakeyaml' ],
    ]
}

dependencies {
    implementation (
        [ group: 'org.flowable', name: 'flowable-http' ],
        [ group: 'org.flowable', name: 'flowable-secure-javascript' ],
        [ group: 'org.flowable', name: 'flowable-spring-boot-starter-process',
            exclude: [ group: 'org.flowable', module: 'flowable-event-registry-spring-configurator' ] ],
    )
}