我已经完成了一个实现,通过 camunda http 连接器从 camunda bpmn 调用 http REST 端点。在这种情况下,首先,BpmnInvokerREST 端点将被调用,提供bpmnProcessId作为路径参数和Authorization键作为带有 requestBody 的标头参数,然后在BpmnInvoker相关的 bpmn 图内将被调用并传递 requestBody 值。在这些 bpmn 任务中,将有一些服务任务将调用 REST 端点。为了从 BPMN 图中调用 REST 端点,我使用了 camunda http 连接器。在这种情况下,我需要将授权密钥作为 http 标头传递给 REST 端点。为此,我将授权密钥添加到变量映射中,并将其作为 bpmn 图中的变量,并添加到图像和 bpmn 图中提到的标题映射中。但问题是因为这个授权的长度通常超过 4000 个字符。因此,它不能通过 camunda 引擎作为字符串传递。我尝试将它转换为另一个对象(例如:byte[] / StringBuffer 等),假设它将被存储为 blob,但在这种情况下,它会在分配给 http 标头时给出 Class Cast Exception。如何在卡蒙达做到这一点?无论如何不要将这些对象存储在数据库中?我注意到有一些选项可以将列类型更改为 Text CLOB/增加大小等。这是个好主意吗?BPMNInvoke.java@Path("/base")public class BpmnInvoker { ProcessEngine defaultProcessEngine = BpmPlatform.getProcessEngineService().getDefaultProcessEngine(); RuntimeService runtimeService = defaultProcessEngine.getRuntimeService(); @POST @Path("/path/{bpmnProcessId}") public Response start(@PathParam("bpmnProcessId") String bpmnProcessId, String requestBody, @HeaderParam("Authorization") String authorization) { Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap = IntegrationUtility.convertJSONStringToMap(requestBody); // Set the Authorization token to the variable map. // Normally this is more than 4000 characters long dynamic key. // It must be set as a http header value when invoking REST endpoint via http connector. variableMap.put("Authorization", authorization); // Invoke the bpmn diagram by calling the startProcessInstanceByKey on runtimeService. ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(bpmnProcessId, variableMap); // rest of the work after completing the process engine }}BPMN图
添加回答
举报
0/150
提交
取消