Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/127.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在camunda中发送变量和消息_Java_Camunda - Fatal编程技术网

Java 在camunda中发送变量和消息

Java 在camunda中发送变量和消息,java,camunda,Java,Camunda,我有一个接收进程,它有一个中间消息事件等待发送进程发送消息 我已经能够在发送过程中通过以下代理代码触发中间消息事件: RuntimeService runtimeService = ProcessEngines .getDefaultProcessEngine() .getRuntimeService(); MessageCorrelationResult result = runtimeService .createMessageCorrelat

我有一个接收进程,它有一个中间消息事件等待发送进程发送消息

我已经能够在发送过程中通过以下代理代码触发中间消息事件:

RuntimeService runtimeService = ProcessEngines
        .getDefaultProcessEngine()
        .getRuntimeService();
MessageCorrelationResult result = runtimeService
        .createMessageCorrelation("my-message-name")
        .setVariable("customer", customer)    //trigger instance where customer matches
        .correlateWithResult();
我的问题是:如何将变量与消息一起从发送进程发送到接收进程?是否有最佳做法?

这就是我迄今为止所尝试的:

// Set the variable after the correlation
runtimeService.setVariable(result.getProcessInstance().getId(),
    "variableToSend", variableToSend);
我尝试在
JavaDelegate
中检索变量,如下所示:

// Access the sent variable
Double sendByOtherProcess = (Double) delegate.getVariable("variableToSend");
// sendByOtherProcess == null
有趣的是,在接收过程中可以通过JavaScript以嵌入式形式检索
variableToSend

我读到这可能是由于同步/异步行为导致的isse


非常感谢您的帮助。

您已经使用
MessageCorrelationBuilder\setVariable
在MessageCorrelationBuilder上设置了一个变量。有关更多信息,请参阅JavaDoc或


正如您所提到的,您希望将消息关联到与给定变量匹配的进程。为此,您必须使用
#processInstanceVariableEquals
方法。

您已经使用MessageCorrelationBuilder上的.setVariable进行了此操作。是的,谢谢!我将
.setVariable
.processInstanceVariableEquals
交换。如果你提出答复,我就接受。我保证下次会仔细阅读文档;)