Flowable 6,如何获取命令上下文

Flowable 6, how to get comand context

我是 Flowable 6 的新手,当我调用 Context.getCommandContext() 时,在某些情况下它 return 是一个空对象。

我的问题是拥有命令上下文需要哪些条件?。就我而言,如果它为空,我可以手动添加一个吗?如果是,怎么做?

Context API 是内部 Flowable API,建议用户不要使用 API。

你不应该手动添加上下文,这是由 Flowable 命令上下文执行处理的。

Command 中调用您的逻辑时,Context.getCommandContext() 不会为空。

我建议的做法是:

managementService.executeCommand(commandContext -> {

    // Do something with the commandContext here

}