Precondition for Camunda process in a REST application












1














In some cases when modeling a process with camunda one might have a precondition that has be to executed. If the precondition fails, the process instance should be stopped, returning an error event.



Now, the problem is that, once the process instance is started, you cannot return a mapped error code as an exception to the client who send the request, since an error can only be caugth with a listener.



public void createEntity(SomeEntity e) {
repository.save(e);
// start a workflow with camunda
startWorkflow(e);

/*
* If the precondition fails, it would be nice to throw an
* exception here, indicating 400 (Bad Request)
*/
}


If this is not possible, a simple solution would be to exclude that part from the workflow and only start it if the precondition is successful. But then, you cannot model the complete process with camunda, only a part of it. Returning 204 (No Content) and fetching the result of the process instance in a second query also seems wrong to me.



So, can you wait for a process instance to finish or at least return a mapped error code to the client within the request?










share|improve this question



























    1














    In some cases when modeling a process with camunda one might have a precondition that has be to executed. If the precondition fails, the process instance should be stopped, returning an error event.



    Now, the problem is that, once the process instance is started, you cannot return a mapped error code as an exception to the client who send the request, since an error can only be caugth with a listener.



    public void createEntity(SomeEntity e) {
    repository.save(e);
    // start a workflow with camunda
    startWorkflow(e);

    /*
    * If the precondition fails, it would be nice to throw an
    * exception here, indicating 400 (Bad Request)
    */
    }


    If this is not possible, a simple solution would be to exclude that part from the workflow and only start it if the precondition is successful. But then, you cannot model the complete process with camunda, only a part of it. Returning 204 (No Content) and fetching the result of the process instance in a second query also seems wrong to me.



    So, can you wait for a process instance to finish or at least return a mapped error code to the client within the request?










    share|improve this question

























      1












      1








      1







      In some cases when modeling a process with camunda one might have a precondition that has be to executed. If the precondition fails, the process instance should be stopped, returning an error event.



      Now, the problem is that, once the process instance is started, you cannot return a mapped error code as an exception to the client who send the request, since an error can only be caugth with a listener.



      public void createEntity(SomeEntity e) {
      repository.save(e);
      // start a workflow with camunda
      startWorkflow(e);

      /*
      * If the precondition fails, it would be nice to throw an
      * exception here, indicating 400 (Bad Request)
      */
      }


      If this is not possible, a simple solution would be to exclude that part from the workflow and only start it if the precondition is successful. But then, you cannot model the complete process with camunda, only a part of it. Returning 204 (No Content) and fetching the result of the process instance in a second query also seems wrong to me.



      So, can you wait for a process instance to finish or at least return a mapped error code to the client within the request?










      share|improve this question













      In some cases when modeling a process with camunda one might have a precondition that has be to executed. If the precondition fails, the process instance should be stopped, returning an error event.



      Now, the problem is that, once the process instance is started, you cannot return a mapped error code as an exception to the client who send the request, since an error can only be caugth with a listener.



      public void createEntity(SomeEntity e) {
      repository.save(e);
      // start a workflow with camunda
      startWorkflow(e);

      /*
      * If the precondition fails, it would be nice to throw an
      * exception here, indicating 400 (Bad Request)
      */
      }


      If this is not possible, a simple solution would be to exclude that part from the workflow and only start it if the precondition is successful. But then, you cannot model the complete process with camunda, only a part of it. Returning 204 (No Content) and fetching the result of the process instance in a second query also seems wrong to me.



      So, can you wait for a process instance to finish or at least return a mapped error code to the client within the request?







      java camunda






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 9:21









      Glains

      873517




      873517





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247358%2fprecondition-for-camunda-process-in-a-rest-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247358%2fprecondition-for-camunda-process-in-a-rest-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()