4 Replies Latest reply on Aug 8, 2013 4:46 AM by bhillou

    Confusion between RuntimeManager and new Kie API in jBPM 6

      Hello,

       

      Mostly due to the (apparent) lack of documentation, I'm quite confused right now as to how to use the new Kie API in JBPM6 vs the RuntimeManager environment.

       

      Ideally I'd like to use OsgiKieModules but also have access to the TaskService, but it's not clear to me how to initialize the enviroment, and looking at the examples or the unit tests I found very different ways to setup things.

       

      So in effect what is the recommended way to setup an runtime environment that includes multiple KieModules that can contain rules, workflows, Java code and Human Tasks ?

       

      Also I'm using Spring so I'd like to avoid mixing CDI and Spring as much as possible.

       

      Thanks a lot for any help or any pointers, because I'm a bit lost at this point !

       

      Best regards,

        Serge Huber.

        • 1. Re: Confusion between RuntimeManager and new Kie API in jBPM 6
          swiderski.maciej

          RuntimeManager is recommended way to use when processes are involved, for rules itself you don't need RuntimeManager as it's tailored for ease of management in BPM world. When it comes to multiple modules I would say that best would be to have top level module that aggregates all dependencies to other modules and then build up KieContainer for it. Once KieContainer is ready it can be used to get important parts of it:

          • KieBase
          • KieSession model

          These two can be consumed by RuntimeManager and the RuntimeEnvironment to provide flexible execution environment. This is the approach that jbpm-kie-services deliver and are fully CDI based.

           

          There has been some work done around RuntimeManager for spring too so might be something to look at. As you already mentioned there is not much documentation yet but soon it will start coming in, meanwhile take a look at kie-spring and kie-aries-blueprint modules of droolsjbpm-integration. Maybe it will bring you something useful if not feel free to open jira for improvements you think are needed.

           

          HTH

          • 2. Re: Confusion between RuntimeManager and new Kie API in jBPM 6

            Hello Maciej,

             

            Thanks a lot for your answer, it helps clarify things a bit. Now I have a few more questions. You talk about setting up a module that aggregates all dependencies, but as I'm dealing with OSGi modules, I cannot know in advance which modules will be deployed or not. Isn't there a way to do this dynamically ?

             

            Also, if I understand you correctly, once I have the KieContainer with all the dependencies, I should use that to initialize the RuntimeManager ? Do I use the RuntimeEnvironmentBuilder to do that ? Any example you could provide would be really great.

             

            I must say that I'm integrating both the BPM and the Rules part, and my OSGi modules contain both. I'm actually in the process of upgrading from jBPM 4.4 all this codebase so I'm struggling a bit in making sure I'm using the new APIs correctly, as I want to avoid using stuff that might get deprecated (as it seems that some of the jBPM 5 code will be).

             

            Best regards,

              Serge Huber.

            • 3. Re: Confusion between RuntimeManager and new Kie API in jBPM 6
              swiderski.maciej

              Serge Huber wrote:

               

              Thanks a lot for your answer, it helps clarify things a bit. Now I have a few more questions. You talk about setting up a module that aggregates all dependencies, but as I'm dealing with OSGi modules, I cannot know in advance which modules will be deployed or not. Isn't there a way to do this dynamically ?

              What I meant is if you have dependent modules they should be aggregated into single one that will have all those modules defined as dependencies so there will be single unit of deployment that will have access to all required classes and assets. And yes, you can do it dynamically where you'll get one to one relationship between RuntimeManager and KieContainer. You can create RuntimeManagers (and then close) them on demand - meaning it is completely dynamic. That's the same way jbpm console does it, allows you at any time to deploy or undeploy units (kjars).

               

               

              Serge Huber wrote:

               

              Also, if I understand you correctly, once I have the KieContainer with all the dependencies, I should use that to initialize the RuntimeManager ? Do I use the RuntimeEnvironmentBuilder to do that ? Any example you could provide would be really great.

              Yes, best way is to use RuntimeEnvironmentBuilder as it allows you to configure all pieces in quite simple way. There are some helpers in RuntimeManager that helps to set it up. Take a look at:

              KModuleRegisterableItemsFactory  this shall be used to setup KieSessions by RuntimeManager when RuntimeEngine is created. It uses kmodule.xml definitions to find the right configuration.

              In general what you would need to do is:

              1. create default RuntimeEnvironment using RuntimeEnvironmentBuilder

              2. set KModuleRegisterableItemsFactory as registerableItemsFactory on builder

              3. set KieBase taken from KieContainer on builder

              4. set Clasloader taken from KieContainer on builder

              5. most likely set EntityManagerFactory on builder otherwise it will create it's own

              6. based on your user and group management set proper UserGroupCallback on builder

              That should give you complete environment for most of the cases.

               

              I'll be working on examples in upcoming week so hopefully that will give more insight into details.

               

               

              Serge Huber wrote:

               

              I must say that I'm integrating both the BPM and the Rules part, and my OSGi modules contain both. I'm actually in the process of upgrading from jBPM 4.4 all this codebase so I'm struggling a bit in making sure I'm using the new APIs correctly, as I want to avoid using stuff that might get deprecated (as it seems that some of the jBPM 5 code will be).

              Completely understand that, due to the amount of work for 6 we did not have time for documentation and examples but soon these will start coming in which shall make the transition from previous versions easier. Feel free to post questions here so we can make sure code is written in the best way on both ends

               

              HTH

              1 of 1 people found this helpful
              • 4. Re: Confusion between RuntimeManager and new Kie API in jBPM 6

                Hello Maciej,

                 

                Thanks a lot, again your answer was very detailed and helpful.

                 

                Best regards,

                  Serge Huber.