4 Replies Latest reply on Oct 26, 2005 11:32 AM by Ronald van Kuijk

    jBPM application

    Joshua Tree Newbie


      I need to develop an application that works with jBPM and JMS. I need to instantiate processes for each message received in a specific queue. Currently, I am using a MDB for handling the consuming of messages and an CMP (EJB) for jBPM logic. Each message received, invokes a method on the CMP (through an interface) that starts a process instance and so on. The problem is that when my process takes too much time to complete, that increases MDB instances running concurrently.

      Is it possible to instantiate processes and let them run in background (asynchronous)?
      Any suggestions of another way to build this application (without the CMP maybe)?

      Thanks joshua

        • 1. Re: jBPM application
          Ronald van Kuijk Master


          MDB -> startprocess

          good idea, although your problem of long running processes is a design error on your side. If you started the process, the mdb can end. Processes by themselves are asynchronous.

          EJB (cmp) -> for jBPM logic

          hmm... entity beans should according to good practice not contain logic. Certainly not jBPM logic. Or do you mean you wrapped the jBPM factory in a sessionbean?

          • 2. Re: jBPM application
            Joshua Tree Newbie

            Hi again, and thanks helping,

            What you mean with ?Processes by themselves are asynchronous?? Inside my OnMessage method if I invoke a EJB method that instantiates a process instance, the OnMessage method only ends when the process ends, right? It does not run in background, right? The call waits until the process instance ends (I think).

            public void onMessage(Message msg) {
            try {
            if (msg instanceof TextMessage) {
             String order = ((TextMessage) msg).getText();
             Queue queue = (Queue) msg.getJMSReplyTo();
             Document rfs = null;
             StringReader xml = new StringReader(order);
             try {
             synchronized (parser) {
             parser.parse(new InputSource(xml));
             rfs = parser.getDocument();
             } catch (SAXException esax) {
             System.out.println(": XML inválido: " + order);
             } catch (IOException eio) {
             if (rfs.getElementsByTagName(Confirmacao).getLength() > 0) {
             log.info("Confirmação recebida");
             if (queue != null) {
             if (rfs.getElementsByTagName(Resposta).getLength() > 0) {
             log.info("\n\n" + order);
             else {

            About the CMP, my jBPM logic is outside the CMP, the logic is implemented with action handlers. Yes, I use the CMP for wrapping the sessionfactory, because I don?t want to create a sessionfactory for each ejbCreate, and I had to do that with SessionBeans.

            • 3. Re: jBPM application
              Joshua Tree Newbie

              Sorry, i did not want to put all that code.

              Anyway, the gestor is a local interface for the CMP.
              For each type of message i get, i call the proc_order_req or the proc_order_resp and the onMessage only ends when the process instance ends. Has I told you before, I use a CMP because if the MDB container needs another instance of the CMP LocalHome interface it will not have to create a new seesionfactory again. And i cannot do that with Stateless Session Beans.

              Thanks Joshua

              • 4. Re: jBPM application
                Ronald van Kuijk Master

                Again I would not use business logic in a CMP/EJB. Besides that, once you start the process, the method returns and the bean can stop. Show me the code in the gestor please. I think you are either doing someting wrong or have written a 'piece of code that signals all states/tasks/... etc and when the process is in the end node, returns

                Not having to create the sessionfactory is something the jbpm.sar file takes care of. Do you use that (if you run on jboss)