1 2 Previous Next 20 Replies Latest reply on May 11, 2007 4:23 PM by jliptak

    Is it possible to update a process def without versioning it

    mgjadoul

      Let suppose that a process is wrong, but that process instances already exist for it.
      These process instances could be blocked, and you probably could delete them. But, doing that, the user would need to restart the process from begining.

      Is there something allowing to 'upgrade the process' in a way that the existing process instances could be unblocked?

      Eventually by migrating a ProcessInstance to a new version of the ProcessDefinition. Would that be possible?

        • 1. Re: Is it possible to update a process def without versionin
          enazareno

          I am also thinking about this problem. I hope somebody will have a good solution for this. I will try to keep watch on this issue.

          Regards,

          Elmo



          • 2. Re: Is it possible to update a process def without versionin
            brittm

            If I'm not mistaken, you can dynamically modify running processes, ie. add nodes, transitions, etc. thorugh the APIs. This would not change the version of the deployed process definition. You would likely want to code a little "bug fix" application and run it against all process instances that need to be changed.

            So, it is possible; there just isn't a declarative way to do it.

            -Britt

            • 3. Re: Is it possible to update a process def without versionin
              tom.baeyens

              you can update process definitions. (you have to evict the process definitions in hibernate's second level cache, though)

              it is not encouraged, just as modifying java byte code in a running program is not encouraged. you can get into trouble real easy.

              same goes for migrating process instances to a newer version. we plan to provide some support for it in the future, but it is easy to end up trouble.

              regards, tom.

              • 4. Re: Is it possible to update a process def without versionin
                enazareno

                Yes, I agree, editing the definition on the fly might produce more problems than solutions esp. with ongoing process instances. Maybe it might be OK if your changes pertain only to additonal notifications, but not something that will change the flow of the process. I feel it might occur with very long processes, one that will probably take many months or years to complete. Business rules might change in the middle of the process.

                It is one of the things that I want to avoid, I feel fine with versioning, however in real-case scenarios, I am anticipating that this will happen, especially if theres a flaw in the analysis. So I am thinking in the lines of probably rerouting the flow from the old version to the updated version. It might become very complicated, but it's something we have to be prepared for.

                Regards,

                Elmo

                • 5. Re: Is it possible to update a process def without versionin
                  ralfoeldi

                  Hi Elmo,

                  just a thought: wouldn't it be worth the effort to implement migration classes?

                  What I am suggesting is not to change existing process defintions but to define new, changed processes, define a migration class that gets and terminates all process instances of the old process definition and 're-starts' the process instances at the correct point in the new process.

                  The default migration class would map nodes to nodes etc. and you would only have to take care of the complicated stuff that comes up in specific processes and cannot be genrically handled.

                  This isn't trivial but should be worth it, if this happens more than once every other year. (I once hacked a jBPM 2.0 DB to change a process definition and the instances. It wasn't fun and I would have implemented what I described above, but we had a pretty panicy business side that wanted changes 'NOW'.) Other advantages would be data integrity etc.

                  Happy New Year!

                  Rainer

                  • 6. Re: Is it possible to update a process def without versionin
                    enazareno

                    Hi Rainer,

                    I think your suggestion is great. Please check if I have understood you correctly:
                    1. Create the new process definition
                    2. Specify the process instance you want migrated to new definition
                    3. The tool checks to see if the completed nodes matches or is still valid for the new definition, if invalid it throws an error
                    4. If successful it changes the processinstance graph with the new process definition (4a. in your experience should it recreate the transactions and the delete the old process instance, or 4b. just update the process defintion foreign keys, is this possible with the data constraints? )

                    If I have assumed correctly above, I have a few questions to keep things interesting though, lets assume I have a process definition as follows: A-B-C where A is the main process and B and C are subprocesses. Only B subprocess needs to be updated, should I:

                    a) migrate only affected process, i.e. B?
                    a) recreate the whole processes A,B and C?
                    b) recreate the affected processes only i.e. A and B

                    Sorry for too many questions. I plan to change some existing processes using jbpm and before I do that, at least I must have a plan just in case. It may not happen but I see this as potential risk. You know how it can be funny in this business, its best to assume things could go wrong. I hope these questions will not add to your new years hangover ;)

                    Regards,

                    Elmo









                    • 7. Re: Is it possible to update a process def without versionin
                      ralfoeldi

                      Hi Elmo,

                      my ideas just a tiny bit different. I am always for using an API instead of directly going to the DB and changing things.

                      What I would do is:
                      - end the old processInstance
                      - create a new processInstance and map the state of the old processInstance to the new one
                      - I would NOT change existing processInstances (except for ending them)

                      as that's just hot air a more detailed version:

                      - create a migration base class that takes an active processInstance (with an old process definition) and a new process definition. The migration class would end the old processInstance, create a new one and try to create and correctly place matching tokens in the new processInstance. It could furthermore create a log, migrate variables, keep a link to the old processInstance, etc. The main motivation to do this is to keep data integrity and being able to reproduce what happened. If you just change the database you don't have a chance of ever reproducing a process (including the defintion change).

                      - the migration base class will only work if the old and new processDefinition structures match, otherwise it should throw an excpetion. In this case you need a specific implementation.

                      - if the structure of the processDefinition has changed or specific actions are needed to migrate, implement a specific subclass that would override a "mapNode()" method. This would e.g. allow you to merge two tokens in a fork if the fork no longer exists or do other - possibly very complex - addaptions required by the changes to the processDefintion. You would only need to implement those node migrations that will not work by default.

                      It would probably make more sense to change all active processInstances of a deprecated processDefinition. But that doesn't effect the overall concept.

                      Now none of these things are trivial, but it shouldn't be that hard to do. Depends on how important this will be for you.

                      Problems would be:
                      - how to recognize the versions of processDefinitions. You can't rely on the version as that would / could change depending on deployment. You would problably have to implement your own - static - versioning that would survive e.g. multiple deployments.
                      - almost same problem: mapping specific migrations (processDefA.1=> processDefA.4) to a specific migration class implementation.
                      - how to recognize structures (node, etc.) By Name? By path? Again, an id will change so you would have to implement so kind of logic / convention that could figure this out.
                      - plus lots of other things you only find out when you write the code :-)

                      Subprocesses? No idea. I guess changing the subprocess and relinking the main process should do, but then again you'll probably run into a lot of problems.

                      New Years hangover? :-) Your questions will go unnoticed in that respect. Too much background noise....

                      Hope this helps. Might even implement it myself. Depends on what my current project requires.

                      Rainer

                      • 8. Re: Is it possible to update a process def without versionin
                        mgjadoul

                        Hi,

                        This seems a more complex that what I believe I would need. The basic process migration would seems enought for me.
                        In general, I suppose that if we want to change a process, it is because the current process has some bugs and is eventually blocked somehow.
                        Other possibility is that there is a security problem in a process.
                        In a first version of JBPM allowing the upgrade of a process, it could be required that the structure has to be exactly the same or allow only adding nodes and transitions.
                        In this way, the the mapping is very simple.
                        Concretly, I had a simple test where I did not forseen a cancel transition in a task. Simply addind the transition without changing the other nodes/transitions was enought.

                        Marc

                        • 9. Re: Is it possible to update a process def without versionin
                          enazareno

                          Hi,

                          Yes, you could definitely update definitions on the fly as what was discussed. I just don't know if there is a way you can view the updated xml definition from the process definition you updated backdoor. I guess you just need to keep track of it.

                          And also, you are fine as long as you are not running in a 24/7 environment, otherwise you need to evict the definition as suggested:

                          you can update process definitions. (you have to evict the process definitions in hibernate's second level cache, though)


                          @tom
                          BTW, how do you evict a process definition?

                          Regards,

                          Elmo

                          • 10. Re: Is it possible to update a process def without versionin
                            camunda

                            Hi.

                            cancel ProcessInstances and start complete new processes is often impossible (because of triggering external systems, sending mails t ocustomers, ...) so we have the solution, that we can change one processInstance to a new version if the new version has
                            - the same states with the same names for active tokens
                            - the same tasks with the same names for active tasks

                            This code is embeded in our toolkit for jbpm (which will be open source, we plan to release it at the end of january), here it is:

                             public void changeProcessVersion(long processId, int newVersion) {
                             checkSession();
                            
                             ProcessInstance pi = jbpmSession.getGraphSession().loadProcessInstance(processId);
                             ProcessDefinition oldDef = pi.getProcessDefinition();
                             Node oldNode = pi.getRootToken().getNode();
                            
                             ProcessDefinition newDef = jbpmSession.getGraphSession().findProcessDefinition(oldDef.getName(), newVersion);
                             Node newNode = newDef.findNode(oldNode.getName());
                            
                             pi.getRootToken().setNode(newNode);
                            
                             // do: pi.setProcessDefinition(newDef);
                             try {
                             Class clazz = ProcessInstance.class;
                             Field field = clazz.getDeclaredField("processDefinition");
                             field.setAccessible(true);
                             field.set(pi, newDef);
                             field.setAccessible(false);
                             }
                             catch (Exception ex) {
                             throw new ConfigurationException("can not set processDefinition on processInstance with reflection. check nested exception for details.", ex);
                             }
                            
                             Iterator<TaskInstance> iter = getTasksForProcesInstance(jbpmSession, pi).iterator();
                             while (iter.hasNext()) {
                             TaskInstance ti = iter.next();
                            
                             Task oldTask = ti.getTask();
                             // find new task
                             Query q = jbpmSession.getSession().createQuery( HibernateQueries.findTaskForNode );
                             q.setString("taskName", oldTask.getName());
                             q.setLong("taskNodeId", newNode.getId());
                             Task newTask = (Task) q.uniqueResult();
                            
                             ti.setTask(newTask);
                             }
                            


                            We have no problems with that code, if the preconditions are met.

                            Note, that you can not make complexe changes to processes and migrate old versions to the new ones. But it is helpful if you must deploy a bug fix of a process (or a Java class, included in the procsess).

                            Hope that helps, feedback is welcome :-)

                            Bernd
                            camunda GmbH

                            • 11. Re: Is it possible to update a process def without versionin
                              ralfoeldi

                              Hi Bernd,

                              I can't resist...

                              cancel ProcessInstances and start complete new processes is often impossible (because of triggering external systems, sending mails t ocustomers, ...)


                              What I suggested was ending the old processInstance and starting the new one in the same or matching state so you wouldn't be triggering anything twice. (Resending mails is a problem that has to be solved differently anyway as it isn't transactable.)

                              The problem I have with directly changing the database is 'revision-safe' data. Especially in long running or archieved processes you would have no chance of reproducing workflow execution as you have no way of knowing what definition was used for what processInstance. (If customer internal security forbids direct write access to production databases this would probably be forbidden as well.)

                              Think: Customers calls and claims you sent a mail 2 months ago. You changed the processDefinition. What chance do you have of being sure (unless you map / log all actions somewhere else).

                              But of course I am totally aware that hardly anybody cares about these things except for internal revision departments :-)

                              Greetings

                              Rainer





                              • 12. Re: Is it possible to update a process def without versionin
                                camunda

                                I think this is a real problem! But in our application we have simply solved that by adding a processVariable for the running version and changed that if we "upate" a process version.

                                The jbpm-log then keeps track at which time in the process execution the version was changed (and the old and new version number).

                                So we know whats going on...

                                starting the new one in the same or matching state


                                How do you do this with jBPM? Some kind of hack to get a process in the state you want?

                                • 13. Re: Is it possible to update a process def without versionin
                                  ralfoeldi

                                  Hi Bernd,

                                  well first of all I said 'I would' so it was basicly hot air, nothing more. I also mentioned that I 'might' even implement it myself. So I didn't even promise to do it :-) (But I did descride the idea in some detail in this thread.)

                                  Problem is that no customer was yet willing to pay for the routine (nobody had a real need, though this might be coming) and I'm personally booked 110%.

                                  But I'm realy interested in doing it, so maybe... in a few weeks I can tell you more.

                                  Greetings

                                  Rainer
                                  ------------------------------------------------
                                  Not only Microsoft can produce vaporware

                                  • 14. Re: Is it possible to update a process def without versionin
                                    camunda

                                     

                                    I'm personally booked 110%


                                    I would be happy to have so much free time ;-)

                                    OK, I can image that we implement it in one of our projects and let you know if we have done it...

                                    1 2 Previous Next