flowable-engine icon indicating copy to clipboard operation
flowable-engine copied to clipboard

Incoming event starts process for suspended process definition

Open wvlancke opened this issue 3 years ago • 3 comments

Describe the bug I have set up a process definition with a start event using the event registry linked to a RabbitMQ channel.

Everything works as expected when sending a message to the RabbitMQ queue.

Afterwards, I suspend the process definition and I send a message to the RabbitMQ queue again.

The message receiver will try to start a process but fails to do so due to the process definition being suspended. The RabbitMQ message is then considered to be in error and is retried, creating an infinite loop.

Expected behavior I would expect starting a process from a suspended process definition id not to happen, or having the event subscription to no longer match the given process definition.

If there is any workaround for this, I would be happy to try this as well.

Additional context Using Flowable 6.8.0 Using Flowable within Spring Boot

wvlancke avatar Feb 17 '23 14:02 wvlancke

@wvlancke , I don't know of a workaround to cancel a suspended definition's subscription. I do, however, have a workaround for the infinite loop. Since you're using Spring Boot, have you considered declaring a dead letter exchange when configuring your inbound queue? For example:

    @Bean
    public Queue workflowInboundQueue(final MyApplicationProperties props) {
        return QueueBuilder.durable(props.getInboundQueue())
                .withArgument("x-dead-letter-exchange", props.getInboundQueueDLX())
                .build();
    }

For truly undeliverable messages, this will send them to your dead letter exchange instead of back to your inbound queue.

Another side effect of the exception you've encountered is that other process definitions subscribed to the same event may fail to execute. Whether they execute depends on the order in which the BpmnEventRegistryEventConsumer processes the subscriptions in its eventReceived() method. Subscriptions processed before the suspended definition will likely succeed, subscriptions after it will never be processed because the FlowableException thrown stops the subscriptions loop. This is true regardless of whether you've configured your Process Engine for asynchronous initiation of Event Registry events: processConfig.setEventRegistryStartProcessInstanceAsync(true);

To work around this side effect, I've extended the BpmnEventRegistryEventConsumer with an eventReceived() override to process each subscription in a try/catch structure, and then set it in my Process Engine configuration: processConfig.setEventRegistryEventConsumer(new DecoupledBpmnEventRegistryEventConsumer(processConfig));

chaserb avatar Jan 04 '24 01:01 chaserb

@chaserb I am seeing the same problem where a suspended process deployment still keeps listening to a rabbit mq queue and also prevents other non suspended processed deployments from listening.

Could you please elaborae on the chnages you made so that I can make the same chnages in my flowable instance. Thanks.

sandey60 avatar Dec 04 '24 06:12 sandey60

Hello @sandey60 , I do not have a solution for the suspended process problem. I am seeing the behavior you've described. All I've suggested to @wvlancke is how to avoid the infinite loops, which you can do by setting up a dead letter exchange.

chaserb avatar Dec 10 '24 16:12 chaserb