1 2 Previous Next 16 Replies Latest reply on Feb 19, 2015 11:51 PM by Alexandre Roger

    JBPM 6 Jbpm-Console does not display processes started from external service

    Joey Teo Newbie

      Looking for help on anyone who has faced the same problem I have with JBPM 6 Console.

       

      Problems statement;

      I've one simple BPMN file, both build & deployed via Kie.

       

      - ) the workflow was designed in Eclipse. pushed to Kie via Git.

       

      In KIE

      - ) Workflow is viewable and correct with Authoring -> Project Authoring.

      - ) Workflow built and deployed.

      - ) Process Definition lists the workflow, upon starting the process, the Instance gets shown in Process Instance List.

      - ) Clicking on Views -> Process Models views the path which the workflow has executed.

       

      Project Instance deployed with external services.

      - ) Workflow is built and deployed as in KIE, similar Workflow

      - ) Process Definition lists the workflow, upon starting the process, the Instance gets shown in Process Instance List.

      - ) Clicking on Views -> Process Models DOES NOT SHOW THE MODEL.

       

      Problem

      - ) If you've clicked on a Process Model deployed through KIE, then clicking on Process Models of Processes from external services shows the previous opened Process Model. Or even wrong Process models for the external Services,

       

      External Service Code;

      Below is my sample of my external Service code to the exact dot.

      try {

           // create the entity manager factory and register it in the environment

           EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.jbpm.domain" );

           Environment env = KnowledgeBaseFactory.newEnvironment();

                env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );

       

           KieServices ks = KieServices.Factory.get();

           KieContainer kContainer = ks.newKieContainer(ks.newReleaseId("groupId", "ArtifactId", "1.0.0"));

       

           //create a new knowledge session that uses JPA to store the runtime state

           org.kie.api.KieBase kbase = kContainer.newKieSession("defaultKieSession").getKieBase();

           StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase , null, env ); //for persistence..

       

           //persistence logger

          JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);

       

           //local variables only for the workflow that is called

           Map<String, Object> params = new HashMap<String, Object>();

           ksession.setGlobal("WORKFLOW_PROCESS","someWorkflowProcessIdentifiyForMySelf");

           ksession.startProcess("WorkflowProcessName",params);

       

        } catch (Exception e) {

             // TODO Auto-generated catch block

             e.printStackTrace();

        }

       

      My Persistence.xml is same as that deployed with jbpm-console.

       

      Observations :
      I've noticed that the JBPM-CONSOLE looks for Definition Name which is externalId in JBPM database for ProcessInstanceLog, NodeInstanceLog & VariableInstanceLog.

      for workflows which is executed through KIE console, the DefinitionName / externalId is the id of groupId:ArtifactId:version and if I patch externalId to the id required, the Process Model can be viewed. However, by default, DefinitionName / externalId is a running number if started from an external service.

       

      I have Googled quite extensively, but there doesn't seem to have any examples out there how to set the externalId via code. Maybe I'm googling wrongly.

       

      Or is this a bug from the JBPM-Console? Since the externalId is already created, why does it need to match that in deployment from Kie Console ?

       

      Any help from all you jbpm users out there?

       

      What could I be doing wrong?

       

      Noob in JBPM and thanks in advance.

       

      Environment : Jboss 7.1.1, jbpm6 as per installed using Ant install.demo for JBPM6.0.0.Final

        • 1. Re: JBPM 6 Jbpm-Console does not display processes started from external service
          Joey Teo Newbie

          I just realized that externalId is actually the id provided by ksession.getId() upon execution. How do I set ksession.getId() which is the process id returned? This should fix this "somehow"

          • 2. Re: JBPM 6 Jbpm-Console does not display processes started from external service
            Mauricio Salatino Master

            Something to check might be.. did you open your business process with the web designer at least once? Did you manage to see the process graph for the process definition that you are trying to open from the runtime views?

            • 3. Re: JBPM 6 Jbpm-Console does not display processes started from external service
              Joey Teo Newbie

              I did manage to see the process graph for the process definition in runtime views.

               

              the problem seems to be the Process Instance only works for Definitions / ExternalId which is string based (groupId:ArtifactId:version) .

              once i patch the db externalId with groupId:ArtifactId:version instead of the provided externalId / ProcessId, the Model View in Runtime in Process Instance view will show.

               

              1) I suspect this is a bug in the jbpm-console? The externalId's are correct (linking both 3 tables, ProcessInstanceLog -> NodeInstanceLog -> VariableInstanceLog ) but it doesn't seem to recognize the Integer based externalId

               

              2) how do we manually set the externalId just like that the jbpm-console does when we initiate a Process Instance from the Process Definition.

              • 4. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                Mauricio Salatino Master

                this doesn't sounds as a bug in the console, it seems more like you are expecting that your external processes works in the console without providing the console all the data that it needs. As you mention the GAV (groupId:ArtifactId:version) are important to the console/kie-workbench because all the runtimes are created based on this deployment ID.

                 

                As I recommended in the other post, most of the time is easier to interact with a remote runtime instead of creating a local runtime inside your project and then hoping that all the process information will show up in the console.  If you want to go this way (which is possible but definitely more laborious) you need to make sure that you use the runtime manager instead of creating the session as you showed in your snippet. The runtime manager will do most of the set ups for you.

                 

                HTH

                1 of 1 people found this helpful
                • 5. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                  Joey Teo Newbie

                  Will look into Runtime Manager. Don't really get much documented on this tho. Sample codes not much around.

                   

                  jz curious that since the ksession provides an auto increment ID, why not also allow us to set it? And since, the external ID already is in the db and shown, even tho not the artifact id, why can't it then just show the diagram?

                  • 6. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                    Joey Teo Newbie

                    since externalId is now the GAV id, and is NOT unique

                     

                    From documentation Chapter 6. Processes

                    A process instance can be signaled that a specific event occurred using

                    ksession.signalEvent(eventType, data, processInstanceId)

                    This will trigger all (active) signal event nodes in the given process instance that are waiting for that event type. Data related to the event can be passed using the data parameter. If the event node specifies a variable name, this data will be copied to that variable when the event occurs.

                    It is also possible to use event nodes inside sub-processes. These event nodes will however only be active when the sub-process is active.

                    You can also generate a signal from inside a process instance. A script (in a script task or using on entry or on exit actions) can use

                    kcontext.getKnowledgeRuntime().signalEvent(eventType, data, kcontext.getProcessInstance().getId()); 

                     

                    IF the processInstanceId == kcontext.getProcessInstance().getId() == externalId  AND to get the monitor working so the external ID == GAV ( which is NON Unique ) == non unique processInstanceId, IF there was 100k process instance running, all 100k have to be executed at a signal instead of just triggering the known process instance if it was unique?

                     

                    wont this be a huge overhead?


                    • 7. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                      Mauricio Salatino Master

                      So the GAV is unique, meaning that there is just one maven artefact matching with a GAV. Don't confuse the session ID with the deployment ID. A deployment can have multiple sessions created from it, so there is a 1 to N relationship there. It seems that you are mixing both, which is definitely not recommended because it doesn't make sense, to me at least.

                       

                      When you signal an event you can set the process instance id. If you don't set the process instance id it will signal all the process that are listening to that event. You will definitely need to keep a list of all the sessions for the deployments that you have.

                      I'm not seeing the huge overhead that you mention, and I think that it is because of the kinda complicated relationship that you are setting up between the deployment id and the ksession id.

                      • 8. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                        Joey Teo Newbie

                        Hi Mauricio

                         

                          I think you misunderstood me.  I understand what you've said and I totally agree with you. 

                         

                        The problem I'm seeing is that the jbpm-console monitor requires the externalId to be the GAV id to have the process model to be drawn and viewed.  If it was the processInstanceId (externalId in the persistence table) which is unique during the session, the jbpm-console doesn't seem to be able to have the process model monitor to draw and view the process instance..

                         

                        maybe i'm also not describing this right.

                         

                        GOAL : To get the JBPM-CONSOLE to view the Process Instance Model at runtime.

                        Process Instance Creation :

                        Method A

                        1) Create process instance externally with custom code. externalId in Process Persistence Tables is unique from ksession processInstanceId.

                        2) Process Instances are listed in the jbpm-console

                        3) Process Instance Models are NOT viewable because the externalId or Deployment Id in the Instance Details is the GAV id.

                         

                        Method B

                        1) Create process instance externally with custom code. externalId in Process Persistence Tables is unique from ksession processInstanceId.

                        2) Process Instances are listed in the jbpm-console

                        3) Process Instance Models IS viewable because the externalId or Deployment Id in the Instance Details is the GAV id.

                         

                        Method C

                        1) Create process instance of the same process is created from console. externalId in Process Persistence Tables is autonomously the GAV ID

                        2) Process Instances are listed in the jbpm-console

                        3) Process Instance Models IS viewable because the externalId or Deployment Id in the Instance Details is the GAV id.

                         

                        Only seems to me that Method B n Method C with the externalId which is the GAV id being the processInstanceId could make the console view the Process Instance Model.

                        • 9. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                          David Norton Newbie

                          New to this thread but think we are experiencing same problem as Joey here. Let me explain our situation so that you can appreciate the situation here.

                           

                          There are 2 two scenarios for your consideration and testing.

                           

                          Using the Process Designer (from within workbench) and subsequently deployed that produces a kjar.

                          1.  When the process is initiated externally (from an application) a valid Process_Instance_Id is returned.

                              1. We can see the process instance listing in the WB Console but…..
                              2. The problem is that we are unable to view the process instance model image.
                              3. After some experimentation we have found that the process instance model  can be displayed if we patch the process instance Id with the GAV (presumably the model image process is using the internal process id)

                           

                          2. When the process is initiated internally (from the WB-Console) it returns the GAV as the Process_Instance_Id – which it clearly isn’t.

                            1. Now the process instance list can be seen and the process model displayed, but…...
                            2. The problem is we need the Process_Instance_Id for event processing
                            3. Also not much use if we want to integrate with an external application (real world)

                           

                          Quite simply - both metheds should operate in a consistent manner and enable both process_id and the process image features to be available.

                           

                          Why is this important?

                           

                          1.  We need the procress instance diagram (image) as this is what is expected by business people who designed the process in the first place – without requiring any additional technical knowledge. 

                          2.The Process_instance_Id is required for triggering events (e.g.  ksession.signalEvent(eventType, data, processInstanceId)(user guide section 6.4.3.2).  This will become essential in high volume processes with where real time event handling is time critical.

                          • 10. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                            Mauricio Salatino Master

                            Hi David, Joey,

                             

                            In the KIE Workbench we are using the following listener to add the identity and the externalID -> https://github.com/droolsjbpm/jbpm/blob/master/jbpm-services/jbpm-kie-services/src/main/java/org/jbpm/kie/services/impl/audit/ServicesAwareAuditEventBuilder.java

                             

                            So you can do the same as the previous class (set the externalId as the deployment id and everything will work) .

                            We recognise that it can be simpler so file a jira issue so we make sure that the runtime manager set ups the correct externalId for you.

                             

                            Regards

                            1 of 1 people found this helpful
                            • 11. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                              David Norton Newbie

                              Hi Mauricio,

                               

                              For give me and I apologise if I don't fully understand - But I need to check before file anything to Jira - otherwise you may fix the wrong thing!

                               

                              If you "correct" the externalId - then I understand that the process monitor (process model image + status) may work but what about the process_Id?  This must be present otherwise we cannot correctly trigger events for the desired (specific) process_instance_Id.

                               

                              Thank you

                              • 12. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                                graeme kitchen Newbie

                                I have created processes (using the simple HR example) externally through a simple rest client and through the console itself but I cannot view the process model from either.  Am I missing something obvious?

                                • 13. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                                  Joey Teo Newbie

                                  thanks for the reply. done a JIRA report and below is the link to the issue.

                                   

                                  https://issues.jboss.org/browse/JBPM-4271

                                   

                                  Grame : do you have persistency set? if you don't you won't get to view the process instance and models.

                                  • 14. Re: JBPM 6 Jbpm-Console does not display processes started from external service
                                    graeme kitchen Newbie

                                    I have everything persisted to a mysql database in so much as I can see records for example on the ProcessInstanceInfo table.

                                    1 2 Previous Next