activitibpmnflowable

Flowable 6, how to get comand context


I am a newbie to Flowable 6, when I call Context.getCommandContext(), in some cases it return a null object.

My question is that which conditions are needed to have a command context?. And in my case, if it is null, can I manually add one. If yes, how to do it?


Solution

  • The Context API is an internal Flowable API and users are advised not to use that API.

    You should not manually add a context, that is handled by the Flowable command context execution.

    When invoking your logic in a Command then the Context.getCommandContext() will not be null.

    What I would suggest is to do something like:

    managementService.executeCommand(commandContext -> {
    
        // Do something with the commandContext here
    
    }