13 Replies Latest reply on Apr 18, 2006 10:48 AM by Jai Singh

    modeling a long running process

    fptoth Newbie

      Hi,

      I've been making good progress getting jbpm running on a production database and have written some test code, etc. But now I'm trying to understand how to get some real work done!

      Part 1:

      Let's say that one thing we have to accomplish in a process is:

      "ftp large file to remote site"

      Assume this will take a "long" while, as in 30 minutes or so. This seems to imply that we don't do this in a normal node, right? Since we don't want a 30 minute database transaction!

      What's the best way to model this in jbpm? I see at least these two options (I'm a beginner!):

      1. Do this in an async="true" node. The process is in a wait state while a separate thread gets this job done.

      2. Set this up as a task, but instead of a user being involved, it's an automated system (maybe like wf.runa.ru "task bots"?). When the task completes, the process continues.

      So how would the experts do this? All advice welcome.

      Part 2:

      However we accomplish the ftp process, these things can happen:

      1. The ftp job works properly. The process continues.
      2. The ftp job fails in some expected way (remote server is down). I can imagine a process definition that somehow does "try again later".
      3. The ftp job fails in an unexpected way. Say for example that the machine running the ftp process crashes. In this case, jbpm will never hear back from the job (either async thread or external task).

      What's the best practice for case #3? And how does the process model know the difference between a failed task and one that's taking a really long time?

      Thanks,

      Fred

        • 1. Re: modeling a long running process
          Koen Aers Master

          Fred,

          For both cases, you should use indeed use the asynchronous features. Certainly for the second case, it is best to rely on JMS because JMS queues are transactional resources that you have control over. You can use MDB's that read the messages from the queues and depending on the outcome of the job done signal the token to return to the previous state and retry, or continue along another transition...

          Hope this helps,
          Koen

          • 2. Re: modeling a long running process
            Zion Zion Newbie

            i'm lost, what's the role of JMS in a ftp action?

            • 3. Re: modeling a long running process
              fptoth Newbie

              My understanding is that the internal asynchronous messaging within jbpm is fairly limited, though it may be enough for my purposes.

              For example, if I needed to run a bunch of ftp jobs at once, I might need a pool of "ftp runner" objects. These would sit around waiting for messages to ftp files. JMS would guarantee that a single request message was sent to one and only one object.

              My sense is that this is well beyond jbpm's internal messaging, but I'm not certain of the details.

              Can anyone comment on just how far you can go with jbpm internal messaging before you need JMS?

              Also, what is the state of JMS support in jbpm? I've seen several references to "to come".

              Thanks,

              Fred

              • 4. Re: modeling a long running process
                Zion Zion Newbie

                i played a little bit with the "async", here is what I got:

                1. create a "task-node" without "task". Using "task-node" because it does not need a human signal as "node". It's automatic.

                2. add the Customized ActionHandler under a outbout transition.

                3. jbpm-web will block for long time when you click "run process" button.

                4. change the task-node.@async to be "true". Now jbpm-web returns html page immediately upon clicking "run process". And you can check the running-instances page.

                NOTE:
                I also tried put long-term Action in after-signal event, it's not called. I guess there is no signal-event; signal-event is always triggerd by a explicitly signal() call.

                I also tried put long-term Action in after-enter event, it doesn't work as async; but works as a normal sync mode.

                • 5. Re: modeling a long running process
                  fptoth Newbie

                  Ok, now I'm lost. What is this "jbpm-web" application? Am I missing a tool? The only thing that I have is the plain "jbpm" war file from the starter kit that contains a demo of the "websale" process.

                  Where is this "run process" button you're referring to? Or is this your code?

                  Thanks,

                  Fred

                  • 6. Re: modeling a long running process
                    Zion Zion Newbie

                    The jbpm web is the war file.

                    If you are using jbpm designer for eclipse:
                    1. create a sample jbpm project
                    2. modify the graph and create a customized ActionHandler
                    3. right click on the ".par" folder and click "deploy par achive" menu, eclipse will ask you for the jbpm server (deault is localhost:8080). It will be posted to the jbpm.war/upload servlet.
                    (alternatively, you can package it as a local file and use jbpm.war/deploy.html to upload the file)
                    4. Now if you go to localhost:8080/jbpm; you will find the new deployed "sample" process.
                    5. There is no "run process" button, sorry for confusing. You should click the "Start Process Link" in the home page.

                    • 7. Re: modeling a long running process
                      fptoth Newbie

                      Thanks, that's helpful. I have been deploying with ant, but I'm happy to know about the upload mechanism.

                      Would you consider posting your test processdefinition.xml?

                      I keep getting validation errors with the eclipse plugin, and it's just as bad when I try writing them manually. I'm collecting examples.

                      Thanks,

                      Fred

                      • 8. Re: modeling a long running process
                        Koen Aers Master

                        Yes, if you want to have robustness you should use JMS instead of the internal asynchronous support, which works well for simple applications, but not for the high end.

                        Regards,
                        Koen

                        • 9. Re: modeling a long running process
                          fptoth Newbie

                          Thanks for your response. But can we learn at what point we need to switch from internal messaging to JMS? What are the problems with internal messaging? How will we know when not to use it? Does it turn blue under load? Does the CPU burst into flames? Excess stomach acid?

                          What is the status of jBPM support for JMS? Are we on our own to integrate our own action code with JMS? Or is there undocumented support? Or is there unreleased code in CVS? Or should we guess?

                          Any hints appreciated.

                          Thanks,

                          Fred

                          • 10. Re: modeling a long running process
                            fptoth Newbie

                            gudake,

                            I've been trying to play with this too. I think I need to have actions on plain rather than on tasks, because I want the external process
                            to control the process flow.

                            Isn't it true that in your experiment with async tasks, the process continued on regardless of what happened in the async action? It essentially "went past" the async action?

                            In my case, I want to do something like:

                            1. Go to "ftp runner" node
                            2. Execute async ftp job
                            3. On normal completion, signal the process to continue normally
                            4. On abnormal completion, signal the process to do something else

                            Does this fit with what you see?

                            Thanks,

                            Fred

                            • 11. Re: modeling a long running process
                              fptoth Newbie

                              Sorry, the above is supposed to say "plain node", but the code got lost.

                              • 12. Re: modeling a long running process
                                Koen Aers Master

                                Fred,

                                There *is* some unreleased code wrt JMS in CVS. It will be released in the 3.2 branch AFAIK.
                                The moment you want to switch is really up to you. If you want to use clustering for instance, you would have to use a clusterable JMS solution. As long as the internal system works for you, there is no reason not to use it... If you want to scale up the high end with really big loads, than you will probably want to use a performing JMS server.
                                So in a way you should estimate (or as you put it guess) what the expected loads are going to be and test if the performance under this load (which you would have to simulate) is ok.

                                Regards,
                                Koen

                                • 13. Re: modeling a long running process
                                  Jai Singh Newbie

                                  I am also trying to some thing like this . I am new to Java and jBPM . Amy simple samples please. I posted something as a new link then I found out this one..

                                  Any thing will be helpful.