4 Replies Latest reply on Apr 29, 2015 8:56 AM by denford

    how to send a message / signal to the relevant Catch Message/Signal Intermediate Event only?

    danutc

      Hi

       

      I need to use throw / catch message / signal intermediate events in our models.

       

      If there are multiple instances of the same process type then the message / signal will be sent to all running instances and this behavior is not desirable.

       

      I found that a message / signal can be specifically directed to a single process using the following method:

       

      void signalEvent(String type, Object event, long processInstanceId)

       

      What are the options to narrow down to the relevant target process? There must be some correlation between the sender and the receiver so that the sender can find the target process ID.

       

      What are the options when dealing with this problem?

       

       

      Thanks

      Dan

        • 1. Re: how to send a message / signal to the relevant Catch Message/Signal Intermediate Event only?
          danutc

          I found that jbpm supports correlation keys to look up processes (section "5.3.3. Correlation Keys" in documentation). Correlation keys could be used to find the target process id for a message or a signal and use it in signalEvent(String type, Object event, long processInstanceId).

           

          Are correlation keys supported by kie-workbench?

           

          I could not find a way to assign a correlation key to a process when starting it from workbench.

          • 2. Re: how to send a message / signal to the relevant Catch Message/Signal Intermediate Event only?
            denford

            Hi Dan,

             

            Did you figure this out, how to send the signal to only some specific process instances? I'm faced with the same challenge.

             

            Mark

            • 3. Re: how to send a message / signal to the relevant Catch Message/Signal Intermediate Event only?
              danutc

              The sender must know the process id of receiver.

               

              It can be done via user interface as it is the case in workbench. The user selects the process to send the message to.

               

              The alternative is to do it programatically. The receiver needs to register with a registry based on some key. The sender would know the key and would be able to look up for target process id.

               

              There is nothing off the shelf to help on programatically way.

               

              Regards

              Dan

              • 4. Re: how to send a message / signal to the relevant Catch Message/Signal Intermediate Event only?
                denford

                Hi Dan,

                 

                Thanks for your reply and for helping. I'm pretty new to jBPM and may be going about this the wrong way, but I have 2 process definitions, say A and B. Instances of B are created after an A instance and the instances of B also maintain a process variable that is more or less the ID of the A that they "relate" to. Then i want, say, a specific instance of A to signal all the relevant instances of B. I assumed there'd be a way to query then iterate over all of the B instances and signal just the ones that have the right ID.

                 

                Not sure if this is making sense. I think the crux of my issue is how to iterate over all of the active process instances - I'm only using the kie workbench. I'm not necessarily expecting you to know the answer and from what you've said maybe it isn't possible (without a custom registry), but just spelling this out in case anyone can help. I have been trying to find some code that i could perhaps use in a script task within process A to do this.

                 

                Thanks,

                 

                Mark