Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-13774

Sending status-based variables (like progress) from External Task to Engine periodically (via specific method)




      User Story (Required on creation):

      Hello Team.
      I hope you are doing well.
      Following this post, handling status-based variables is important (between External task and Engine). So we have some ideas for sending new variables from the External task client to the Engine via dedicated method.

      Functional Requirements (Required before implementation):

      The main goal is to moderate some fields (like Progress and etc) between External tasks and Engine which is used periodically (for example we have a job like recording video that length too long. it should be done with an External Task. as it is a very long process, I need a notify progress that shows how much of the video is recorded).

      As we describe the point, it will be like a specific method for sending status-based params to the Engine.

      According to your contribution  structure, the idea is under Community Extensions category.

      Technical Requirements (Required before implementation):

      We have developed the main module according to the below details.

      As @jonathan.lukas (Camunda Consultant) has described, we added a new variable (like varName=progressVar) in this api :


      and we could get ProcessInstanceId by externalTask.getProcessInstanceId() method.

      Following the rules, we think that it could be a specific method (it would be developed on client-side like External Task or Services) related to sending progress value to the engine. we have developed the below method for this reason.

           * @param processInstanceId is the id of process instance.
           * @param varName           is the name of variable.
           * @param percent           is the precent of progress.
           * @return the resonse status code.
           * @throws IOException
          public static String executRest(String processInstanceId, String varName, int percent) throws IOException {
              HttpClient httpClient = HttpClientBuilder.create().build();
              HttpPut request = new HttpPut(String.format("http://localhost:9999/bpms/api/engine/engine/default/process-instance/%s/variables/%s", processInstanceId, varName));
              request.addHeader("content-type", "application/json");
              StringEntity params = new StringEntity(String.format("{\"type\": \"string\", \"value\": \"%s\", \"valueInfo\": {}}", "% " + percent));
              HttpResponse response = httpClient.execute(request);
              return "Set variable for % " + percent + " of doing external task status code is: " + response.getStatusLine().getStatusCode();

      Limitations of Scope (Optional):

      Hints (Optional):

      It's our pleasure if we can help you with developing the module.
      According to the post, it could be such a necessary feature that would be helpful for users.
      Let me know if it is good enough for sending a merge request (i mean "pull request") or any modification will be needed.

      Thank you in advance


        This is the controller panel for Smart Panels app




              tassilo.weidner Tassilo Weidner
              tahaarian taha arian
              taha arian taha arian
              Tassilo Weidner Tassilo Weidner
              0 Vote for this issue
              2 Start watching this issue