holunda-io / camunda-bpm-taskpool

Library for pooling user tasks and process related business objects.
https://www.holunda.io/camunda-bpm-taskpool/
Apache License 2.0
68 stars 26 forks source link

taskService.saveTask() without changes causes NoHandlerForCommandException #769

Closed lbilger closed 1 year ago

lbilger commented 1 year ago

Steps to reproduce

This is a slight variation on updates attributes via API with update listener where nothing is actually changed in the task. This might seem futile but in our setup, it is used to force a task update after process variables have changed.

The command sent to the gateway is not an UpdateAttributeTaskCommand but an UpdateAttributesHistoricTaskCommand. From that class's description: This command has no command handler in the core and is never sent to it. It is not intended to be sent to the gateway but should be merged into other commands by the accumulator, which doesn't happen if it's the only command.

So the problem is that without changes to the task, no UpdateAttributeTaskCommand is created and thus the UpdateAttributesHistoricTaskCommand stands alone where it never should.

Expected behaviour

Calling saveTask() with no changes to the task itself should create an UpdateAttributeTaskCommand enriched with the current process variables.

Actual behaviour

An UpdateAttributesHistoricTaskCommand is issued which cannot be processed and an exception is thrown:

org.axonframework.commandhandling.NoHandlerForCommandException: No handler was subscribed for command [io.holunda.camunda.taskpool.api.task.UpdateAttributesHistoricTaskCommand].
zambrovski commented 1 year ago

Nice one... Side effects over side effects... Thank you for reporting. Are you already working on a solution?

Without looking on he code, I can think of a filter inside the collector, determining that the historic update command is sent alone and transforms that into an update command then...

lbilger commented 1 year ago

I thought in a similar direction and wanted to implement it, but found that the businessKey is missing in the historic event. Then I saw that Camunda is actually sending the update event, we are deliberately suppressing it in TaskEventCollectorService. So my suggestion would be to just not suppress the update event. I will submit a PR soon.

zambrovski commented 1 year ago

Reopening this, because the merged PR turned the pipeline red.