Works/doesn't Work - SendMessage to process - not firing receiver

1
0
-1

hi there,

Bonita Studio 6.3.3/7, Java 1.7.0.67, Windows 8.1

I have a Process Diagram with three pools

PoolA has one SendMSG task to PoolB on TargetElementA with one ContentItemA value ABC

PoolB has one StartMSG called TargetElementA which receives the msg from PoolA and passes it to a HumanTask that displays the data from ContentItemA

All very easy and it works...took a while but it does work as expected. PoolA fires PoolB and shows the data.

PoolC has one ServiceTask with Groovy Connector source code below. This is supposed to mimic Pool A, it executes without error but does not fire PoolB.

Can someone help please, this is really holding me up.

import org.bonitasoft.engine.api.APIAccessor;
import org.bonitasoft.engine.api.ProcessAPI;
import org.bonitasoft.engine.api.ProcessRuntimeAPI;
import org.bonitasoft.engine.expression.ExpressionBuilder;
import org.bonitasoft.engine.expression.Expression;
import java.util.logging.Logger;

String thisTrace = "SignalNextProcess: "
Logger logger= Logger.getLogger("org.bonitasoft");
logger.severe(thisTrace+"Trace Start");

Expression targetProcess = new ExpressionBuilder().createConstantStringExpression("PoolB");
Expression targetFlowNode = new ExpressionBuilder().createConstantStringExpression("TargetElementA");
 
ProcessAPI processAPI = apiAccessor.getProcessAPI();
 
Map<Expression, Expression> mapA = new HashMap<Expression, Expression>();

Expression messageContentKey = new ExpressionBuilder().createConstantStringExpression("ABC");
Expression messageContentValue = new ExpressionBuilder().createConstantStringExpression("ABCDEF");

mapA.put(messageContentKey, messageContentValue)

try{
        processAPI.sendMessage("SendMsgWithContent-Working-RecvMsg",
                targetProcess,
                targetFlowNode,
                mapA
        );
}
catch(Exception e1){
        logger.severe(thisTrace+"Exception e1: " + e1.message + "\n" + e1.stackTrace);
}
logger.severe(thisTrace+"Trace End");

The log I get is this which shows the code is not failing...but the process is also not firing...

2014-10-16 13:07:29 org.bonitasoft.engine.api.impl.ProcessStarter
INFO: THREAD_ID=155 | HOSTNAME=Mainframe | TENANT_ID=1 | The user <walter.bates> has started the process instance <27> of process <SendMsgWithContent-Working-SendMsgConn> in version <1.0> and id <8570457281865086169>
2014-10-16 13:07:29 org.bonitasoft
SEVERE: SignalNextProcess: Trace Start
2014-10-16 13:07:29 org.bonitasoft
SEVERE: SignalNextProcess: Trace End

HELP! :-)

thanks and regards Seán

Comments

Submitted by haris.subasic on Tue, 10/28/2014 - 18:10

Hello, in your explanation, you talk about ContentItemA with value ABC, while in your code your message has a content with a key ABC and value ABCDEF. Could this be the reason? You can also simply try with an empty content, just to see if PoolB will be triggered. If not, are there any correlation keys that need to be matched, as well?

Submitted by Sean McP on Wed, 10/29/2014 - 14:05

Hi Haris,

thanks for taking a look at this...sorry about the confusion there.

I can confirm that my keys are the same only the data is different to differenciate the outputs when they work.

That is the Manually invoked version is key ABC value ABC, and the code version is key ABC and value ABCDEF.

I've tried with NULL call to PoolB as follows but this doesn't work either...

processAPI.sendMessage("SendMsgWithContent-Working-RecvMsg",
targetProcess,
targetFlowNode,
null);

I think I'm building all the parameters correctly including the Map<Expression, Expression>. But the question as to why it not fire off the process pool and step, especially with no messages to indicate anything is wrong.

We're not using correlation keys..

Thanks and regards Seán

Submitted by haris.subasic on Wed, 10/29/2014 - 14:16

I just got another idea (yes, wild, but...) - are you sure that your PoolB is deployed at the moment when you run the script? Since there is no error, it might be possible that the message is correctly sent, but not matched...

Submitted by Sean McP on Wed, 10/29/2014 - 14:42

Wild idea yes, (and not a silly one as I've fallen foul of this before :-)

All pools are in the same diagram and as Bonita deploys all process pools in a diagram at the same time I can sure they are all deployed.

Submitted by haris.subasic on Wed, 10/29/2014 - 17:13

Did you also make sure that the message that you create in your code:

processAPI.sendMessage("SendMsgWithContent-Working-RecvMsg",

has the same name as the message that is expected by the receive message event in PoolB?

Submitted by Sean McP on Wed, 10/29/2014 - 18:48

Yes...I copied the names from 1) the pool and 2) the task using copy/paste...to make sure I got it right.

The other thing is that this is the same string as used in the manual human task using the Message Connector, which works.

If you know Michael S, he has a copy of the BOS file which he could give you to look at.

Submitted by haris.subasic on Thu, 10/30/2014 - 09:21

After some investigation, I can only invite you to open a ticket for your problem.

1 answer

1
0
-1

Same problem - did you find any solution. Context: n parallel validation tasks, if one exit with "Rejected" the parallel tasks must be cancelled. I chose to use a boundary event "catch message" on the tasks to "cancel". I validated the logic by sending a message with a message taks. With scripting (to avoid cluttering the diagram with n-1 message tasks) the message does not seem to be fired - no catch is seen.

import org.bonitasoft.engine.expression.*
import java.util.Map

def process = apiAccessor.processAPI.getProcessInstance(processInstanceId)
def humantasks
def message
def processAPI

if( task1_result == false ) {
        message = "Cancel start"

        Expression targetProcess = new ExpressionBuilder().createConstantStringExpression("Pool3")
        Expression targetTask = new ExpressionBuilder().createConstantStringExpression("Task2")

        Map<Expression,Expression> messageContent =new HashMap<Expression,Expression>()
               
        processAPI = apiAccessor.processAPI
        processAPI.sendMessage( "AbortValidations",targetProcess, targetTask, messageContent )
}

return message

Comments

Submitted by Sean McP on Fri, 05/22/2015 - 18:35

I did get it to work, I can't remember how, but I know where to look and will do that later, I'll come back to you with that.

In the end though I totally rewrote the various processes work together so as not to use any messaging, I found it a much better and reliable way of doing what I wanted to happen in the process.

I know not much help at the moment, but...feedback for now.

regards

Notifications