1 2 Previous Next 17 Replies Latest reply on Mar 2, 2007 3:51 PM by jorgemoralespou_2 Go to original post
      • 15. Re: Stateless Process Engine executor threading issues
        jorgemoralespou_2

        Perfect. I worked out an engine with what you have told me, and everything works now as I expected.
        Thank you two very much for your help.

        • 16. Re: Stateless Process Engine executor threading issues
          kukeltje

          @Tom,

          You mean to just use nodes that signal the token themsellves once initially triggerd? That is what their example does.... and that example does not scale.... now I'm lost.... completely...

          @Jorge,

          Can you describe or better give an example of what you did for others to see

          • 17. Re: Stateless Process Engine executor threading issues
            jorgemoralespou_2

            Sure I can, Ronald.
            For what we need, as Tom said, we really didn't want to persist our process definition, or the execution of the process instances, or anything at all, so while I was working out the JUnit test you asked me for, and trying to figure out how to make my engine work, I did what you asked me for, create an inline String with my processdefinition, and feed it to my process engine. Also, because I was working outside an AS, I look at the examples, and saw that there is a way to create a ProcessInstance without a JBPMContext. So I did this, and voila, it worked without persistance at all, so I modified my engine, and instead of loading process definitions from database, I load them from a memory repository, through an MBean. I create my repository when I deploy the jboss .sar that holds the definition, implementing action handlers, and web service facade.

            We have done lots of stuff for it to work inside JBossAS.

            Now it runs as we expected. Until we need real persitence for processes, will keep on this. Probably we will keep our previous implementation for something as statefull processes, we will need in the future.

            This is kinda the method we use now.

             public Object executeProcessInstance(String processName, Map request) throws Exception{
             // Get process definition
             ProcessDefinition processDefiniton = myMBean.findLatestProcessDefinition(processName);
             if (processDefiniton == null) {
             throw new Exception("Process definition not found");
             }
            
             ProcessInstance instance = new ProcessInstance(processDefiniton);
             instance.getContextInstance().setTransientVariable("REQUEST", request);
            
             // Execute process
             do{
             instance.getRootToken().signal();
             }while (!instance.getRootToken().hasEnded());
            
             // Check that execution is on a end state. if not, throw exception
             if (!EndState.class.isAssignableFrom(instance.getRootToken()
             .getNode().getClass())) {
             throw new Exception("Process finished not in an End Node");
             }
            
             Object response = instance.getContextInstance().getTransientVariable("RESPONSE");
             return response;
             }
            



            It would be great if we could use the database to store our process definitions, and load the process definition from there, but as I see, for now it's hibernate for all or nothing. :-(

            Also, we did have to keep signaling our home made action handlers. Probably we have done something wrong, but that belongs to other post, I think. ;-)

            Thank you very much for both of you.

            1 2 Previous Next