3 Replies Latest reply on Oct 6, 2011 1:42 PM by swiderski.maciej

    Calling two different work item handler from different nodes

    snyperboss

      Hello All,

       

       

      I saw this write up on creating custom  work item for 'Notification'

       

      http://docs.jboss.org/jbpm/v5.1/userguide/ch13.html#d0e3540

       

       

      Suppose in my work flow if I have two notification at two different locations. How do I configure each to call a different work Item handler.

       

      As per my understanding I can only call

       

      session.getWorkItemManager().registerWorkItemHandler("Notification", new CustomNotifyWorkItemHandler());

       

      which applies to both the notification.How can I have something like

       

       

      session.getWorkItemManager().registerWorkItemHandler("Notification1", new CustomNotifyWorkItemHandlerOne());

      session.getWorkItemManager().registerWorkItemHandler("Notification2", new CustomNotifyWorkItemHandlerTwo());

       

      Do  need o create two custom work item's Notification1 and Notification2?

       

      Regards!

        • 1. Re: Calling two different work item handler from different nodes
          heathcliff

          The idea of handlers and work items is that you have one type of work item that it presents some idea/functionality like "Notification" so i has one handler with different parameters passed to it.

           

          You could also make some generic notifivation handler with attribute specifing behavior and than from that handler delegate execution to apropriate class. this is if you wont different behavion for the same work item.

          • 2. Re: Calling two different work item handler from different nodes
            tsurdilovic

            Hi, as Adam said, the mapping of a service task name to the handler implementation is pre-configured and cannot be changed at runtime afaik. You would either create two different handlers or have one that is smart enough to do whats needed depending on that parameters you pass in.

             

            Hope this helps.

            1 of 1 people found this helpful
            • 3. Re: Calling two different work item handler from different nodes
              swiderski.maciej

              Another approach could be that (of course depending on your process) you create a session and register notification handler A then start the process that executes the notification node then goes to a wait state lets say receive task, so you could dispose the session.

              After a while you load the session and register the second (B) notification handler and signal the process to continue its operation.

               

              That should work since you register the work item handlers on the session upon its creation (either a new one or after loading it from data store).

               

              This is the flexibility that jBPM/Drools gives you but final solution is up to you. Just my two cents

              1 of 1 people found this helpful