7 Replies Latest reply on Mar 9, 2014 10:14 AM by pmehra1

    Java Remote REST API questions

    cdsosi

      Hi community,

       

      I have just downloaded a fresh jBPM6.0.0.Final distribution (full version) .

      I am getting deep into online 6.0.0.Final user documentation and I successfully configure a mysql database.

      Now I want to play a bit with Java Remote Rest API and have some questions about it.

       

      1. I built & deployed the Evaluation process sample into the jBPM ng console and start  instances of it
      2. In a Java application I instantiated a RemoteRestRuntimeFactory object with following parameters :
        1. "org.jbpm:Evaluation:1.0"
        2. new URL("http://localhost:8080/jbpm-console/")
        3. "krisv"
        4. "krisv"
        5. => By the way I think there is a small mistake in documentation and user code. The class mentionned in documentation is RemoteRestSessionFactory although it must be RemoteRestRuntimeFactory if I am not wrong
      3. Got a RuntimeEngine instance (remoteRestRuntimeFactory.newRuntimeEngine())
      4. Got a KieSession instance (runtimeEngine.getKieSession())

       

      My question is why do I get an empty list when I call ksession.getProcessInstances()?

      I was expected to get a list with my two instances created inside jBPM console ng.

      a) Is it because the session instanciated inside my Java application is not finally the one that created these two instances and is not the one that can be used to interact with them?

       

      Is the the Java Remote REST API able to respond to the following requirements?

      b) If I want to retrieve all process instances regardless a special deployment id how would I achieve that?

      c) If I want to retrieve all process definitions regardless a special deployment id how would I achieve that?

       

      Thanks for helping / answering !

       

      KR

        • 1. Re: Java Remote REST API questions
          swiderski.maciej

          Franck cdsosi wrote:

            1. => By the way I think there is a small mistake in documentation and user code. The class mentionned in documentation is RemoteRestSessionFactory although it must be RemoteRestRuntimeFactory if I am not wrong

          good catch, we will update documentation

          Franck cdsosi wrote:

           

          My question is why do I get an empty list when I call ksession.getProcessInstances()?

          I was expected to get a list with my two instances created inside jBPM console ng.

          a) Is it because the session instanciated inside my Java application is not finally the one that created these two instances and is not the one that can be used to interact with them?

           

          this is the intended behavior when using jBPM with persistence. This method will return empty list as the process instances are stored in data base and are loaded on demand only when about to be executed. You would notice exactly same results when using directly (no remote api in between) ksession when persistence is enabled.

          Franck cdsosi wrote:

           

          Is the the Java Remote REST API able to respond to the following requirements?

          b) If I want to retrieve all process instances regardless a special deployment id how would I achieve that?

          you should use history operations to fetch such information as it is then based on simple data base query that accesses audit information.

          Franck cdsosi wrote:

          c) If I want to retrieve all process definitions regardless a special deployment id how would I achieve that?

           

          this might not be possible at the moment but feel free to file jira issue for it

           

          HTH

          • 2. Re: Java Remote REST API questions
            cdsosi

            Hi Maciej,

             

            Thanks you very much for your quick replies. It is always appreciated

             

            Just some other questions to clarify :

             

            Franck cdsosi wrote:

             

            My question is why do I get an empty list when I call ksession.getProcessInstances()?

            I was expected to get a list with my two instances created inside jBPM console ng.

            a) Is it because the session instanciated inside my Java application is not finally the one that created these two instances and is not the one that can be used to interact with them?

             

            >>this is the intended behavior when using jBPM with persistence. This method will return empty list as the process instances are stored in data base and are loaded on demand only when about to be executed. You would notice exactly same results when using directly (no >>remote api in between) ksession when persistence is enabled.

             

            So to rephrase your answer, when persistence is enable the getProcessInstances method will always return an empty list, right?

             

            b)

            Franck cdsosi wrote:

             

            Is the the Java Remote REST API able to respond to the following requirements?

            b) If I want to retrieve all process instances regardless a special deployment id how would I achieve that?

            >>you should use history operations to fetch such information as it is then based on simple data base query that accesses audit information.

             

            I don't understand why a deployment id parameter is necessary in URL as all process instances are return regardless specified deployment id?

            In user documentation at the beginning of 17.1.3 (History calls,  Important), it said that "History REST calls is not limited to the deployment specfied by the deploymentId part of the URL used". Again so why deployment id is necessary in URL? Could you elaborate a bit about that because it not clear to me. Actually jBPM6.0.0 is aimed to simplify (Kie)Session and (Kie)Base handling so why this deployment id notion has been introduced? I would have expected to query / interact with "jBPM" in the simpliest way as possible.

             

            Another question about this deployment id notion and Remote API. At the moment you must specified a particular deployment id (first parameter of JAVA constructor), this assumes that you know in advance this deployment id !

            If I want to make a more generic tooling, is there a way to interact with "jBPM" regardless a specific deployment Id? If no is the answer alternative question : How to retrieve all deployed deployment ids? The drawback of this approach is that it needs the creation of as many RuntimeEngine as number of deployment ids.

             

             

            Franck cdsosi wrote:

            c) If I want to retrieve all process definitions regardless a special deployment id how would I achieve that?

             

            >>this might not be possible at the moment but feel free to file jira issue for it

            Done => [JBPM-4178] REST API Enhancement to retrieve all process definitions - JBoss Issue Tracker

             

             

            Thanks for helping !

            • 3. Re: Java Remote REST API questions
              swiderski.maciej

              Franck cdsosi wrote:

               

              Hi Maciej,

               

              Thanks you very much for your quick replies. It is always appreciated

               

              Just some other questions to clarify :

               

              Franck cdsosi wrote:

               

              My question is why do I get an empty list when I call ksession.getProcessInstances()?

              I was expected to get a list with my two instances created inside jBPM console ng.

              a) Is it because the session instanciated inside my Java application is not finally the one that created these two instances and is not the one that can be used to interact with them?

               

              >>this is the intended behavior when using jBPM with persistence. This method will return empty list as the process instances are stored in data base and are loaded on demand only when about to be executed. You would notice exactly same results when using directly (no >>remote api in between) ksession when persistence is enabled.

               

              So to rephrase your answer, when persistence is enable the getProcessInstances method will always return an empty list, right?

               

              correct

               

              Franck cdsosi wrote:

              b)

              Franck cdsosi wrote:

               

              Is the the Java Remote REST API able to respond to the following requirements?

              b) If I want to retrieve all process instances regardless a special deployment id how would I achieve that?

              >>you should use history operations to fetch such information as it is then based on simple data base query that accesses audit information.

               

              I don't understand why a deployment id parameter is necessary in URL as all process instances are return regardless specified deployment id?

              In user documentation at the beginning of 17.1.3 (History calls,  Important), it said that "History REST calls is not limited to the deployment specfied by the deploymentId part of the URL used". Again so why deployment id is necessary in URL? Could you elaborate a bit about that because it not clear to me. Actually jBPM6.0.0 is aimed to simplify (Kie)Session and (Kie)Base handling so why this deployment id notion has been introduced? I would have expected to query / interact with "jBPM" in the simpliest way as possible.

               

              Another question about this deployment id notion and Remote API. At the moment you must specified a particular deployment id (first parameter of JAVA constructor), this assumes that you know in advance this deployment id !

              If I want to make a more generic tooling, is there a way to interact with "jBPM" regardless a specific deployment Id? If no is the answer alternative question : How to retrieve all deployed deployment ids? The drawback of this approach is that it needs the creation of as many RuntimeEngine as number of deployment ids.

              I think it was just scoped into runtime resource and thus under deployment id path as well. As stated in the docs you can safely omit the deployment id while getting history details.

               

              when it comes to deployment id usage in general, I would say it's the same way as you would need to know process id that you would like to start. I agree that there are missing methods to simplify this like get deployment ids, get processes for deployment id which would then help out on finding right information on that. There is on going work to add deployments into REST (remote api) so please feel free to drop another jira with what you see might be important.

               

              HTH

              • 4. Re: Java Remote REST API questions
                cdsosi

                Thanks Maciej for your precisions.

                 

                As far as process id knowing before starting a process is concerned I agree with you but I am a bit doubtful about the fact that you must also know the deployment id.

                The only reason why it may be useful to my opinon is if a deployment id can be viewed as a kind of namespace that is to say two processes with same id can exist in different deployment ids... But I may be wrong because of my small knowledge about version 6 of jBPM

                 

                Anyway thanks again !!

                • 5. Re: Java Remote REST API questions
                  swiderski.maciej

                  deployment id identifies the runtime container that manages the given set of processes (and other assets) as they might be configured differently. Like different runtime manager strategy, different kbase configurations etc. So all that is hidden by single deployment id and that's why it's important. Allows you to run processes and their services in isolation as well. Just to say the least about it

                   

                  while playing more with v6 you'll see why it's important and useful ... I hope

                   

                  HTH

                  • 6. Re: Java Remote REST API questions
                    gulamnadim

                    Hi

                    I am Stuck in my project. I want to add Image Processing debug option which show currently executing node and I have also done database connectivity with persistence. So now my question is it possible to implement both functionality in same project?

                     

                    Nadim

                    • 7. Re: Java Remote REST API questions
                      pmehra1

                      In the REST calls currently for the process, to get details for a specific process, other than the deployment id the procInstId is also required. This means that currently we can only get the details of a process that's been started? What if we need the details of a process in general and what all tasks it has before it has started? I basically want to retrieve the tasks under a particular process even though it is not started. Is there a way to do it currently using the REST API?