5 Replies Latest reply on Feb 2, 2015 1:30 AM by Maciej Swiderski

    Multi JVM

    Vitaliya Zhuravleva Newbie

      Hello dear developers team. we use jbpm 6.1 in our project (internet shop) and we decide to share one session for all customers (just one process instance for one customer). and my question is - is there any mechanism for dividing one running jbpm engine between multi JVM? reason for this is scalability.

      PS persistance base is mySQL.

        • 1. Re: Multi JVM
          Maciej Swiderski Master

          there is no need to share ksession between jvms. It's enough to use Per Process instance strategy that will give you single process instance bound to ksession and that will be used by single customer. The only thing you need to add is the correlation between your customer and the given process instance. You can do it in two ways:

          • use correlation key support in jbpm
          • add some logic into your system that will map process instance id with your customer id

          Why this is needed? It's because to get hold of RuntimeEngine when using per process instance strategy process instance id is always needed.

           

          HTH

          • 2. Re: Re: Multi JVM
            Vitaliya Zhuravleva Newbie

            ok! thank you for replay.

            I got another qestion.

            I configure RuntimeManager and RuntimeEngine next way:

            @Bean( name = "manager" )
                public RuntimeManager getRuntimeManager()
                {
                    RuntimeEnvironment environment =
                        RuntimeEnvironmentBuilder.getEmpty().addAsset( ResourceFactory.newClassPathResource( "com/sample/catalog.bpmn" ),
                                                                      ResourceType.BPMN2 ).get();
                    return RuntimeManagerFactory.Factory.get().newPerProcessInstanceRuntimeManager( environment );
                }
            
            
                @Bean
                @DependsOn( "manager" )
                public RuntimeEngine getRuntimeEngine()
                {
                   runtimeEngine = getRuntimeManager().getRuntimeEngine( ProcessInstanceIdContext.get() );
                         return runtimeEngine;
                   }
            

            and I try to test next situation - run one ksession and start two ProcessInstances in it. then close everything - ksession, RuntimeManager, RuntimeEngine . then get new instances of those and continue processInstance. but I cant get access to ProcessIntances I got in first test But if I do the same but without restart  RuntimeManager, RuntimeEngine  just get new ksession - I can continue ProcessInstances.

            Help me please how to solve my problem !


            PS of course I use persistance in my project

            Best regards!

            • 3. Re: Multi JVM
              Maciej Swiderski Master

              make sure that you create runtime manager only once within your application and then reuse that instance throughout the life time of the system. Then on each request get RuntimeEngine out of it and work with its ksession and task service, once done dispose runtime engine via runtime manager. Don't dispose ksession manually.

               

              That way you'll get all pieces configured and ready to use in your system.

               

              HTH

              • 4. Re: Multi JVM
                Vitaliya Zhuravleva Newbie

                ok, I got it!

                But dear Maciej I have one more  question - Is it right that I can't run another RuntimeEngine on second JVM and upload ksessions stored in persistance (this ksession were run under another RuntimeManager on first JVM)

                Best regards!

                • 5. Re: Multi JVM
                  Maciej Swiderski Master

                  it is completely fine when you use per process instance strategy. Not when you use singleton as they both JVM will work on same instance and thus cause optimistic lock exceptions.

                   

                  HTH