after reviewing docs and see the unit tests, I see that Delegate Expressions seem to be required for Spring autowiring to function.
while the example in the docs: https://docs.camunda.org/get-started/spring/service-task/ show the usage of a expression, there is no actual explanation of the impacts of using the Expression vs not… This surely should be highlighted in MUCH more detail and made as a very visible warning.
I think this does a good explanation: https://stackoverflow.com/a/53927056, but this information should really be added into the docs in a very visible area, and should be updated in the Camunda Spring Boot examples to explain the WHY expression delegate is should be used, and if not used, what are the impacts (such as Autowiring not working within the Delegate’s execution)
typically, you use the Consumer pattern (functional interface), so it is clear that your one class for one service task will be called with the execution context (DelegateExecution).
For this use case the JavaDelegate defines the interface void/execution. It is very clear what happens and you do not have to pass the execution manually, just write ${myServiceDelegate}.
You could however also use an expression and call it via ${myServiceDelegate.execute(execution)}, which has the same effect. When doing so, you are free to pass additional parameters … we sometimes use this when we need to pass a variable value to set in the delegate …
Rule of thumb (at least for me): use JavaDelegates with DelegateExpression always, never use Class, switch to expression if you really need to.
@jangalinski are there other nuance usage for springboot camunda that could be documented? I am happy to update the docs, but would like to capture as many nuances as possible.
Well you part creator and using it from memory. It’s more about identifying and documenting those parts that are in your memory but not actually written down. The Spin plugin is another good example.