Communication between two BPM, Web Service/JavaDelegate

Hi everyone!
I’m developing a project with a BPMN, Camunda and it should interacts with some external Web Services.

I have two different BPM in two different Eclipse projects, that you can find just attached here.

BPM B - Buyer
BPM A - Home Holder


I couldn’t upload more then one image so I had to put all together, but they are saved in two different BPM.

There should be communication between two projects but until now it goes only in one direction. Let me explain better. The logic under the project is that process A expose a Web Service to B to enable B to communicate with it.

The workflow is started by process B, calling the Web Service to fire the start event in process A. This works pretty well. The problem arise when A, after processing the message given by B, wants to reply to him.
Should I create also a WS on B and invoke it from A to communicate with it?

Furthermore, trying a workaround using a simple Java Class that implements a JavaDelegate, when I want to communicate with B, pointing to a Start Event, works well:

runtimeService.startProcessInstanceByMessage(“message”, variables);

But when I try to fire an Intermediate Catch Event on B like that

Execution executionTarget = runtimeService.createExecutionQuery()
.messageEventSubscriptionName(“rispostaProposta”)
.processVariableValueEquals(“executionId”, executionId)
.singleResult();
runtimeService.messageEventReceived(“rispostaProposta”, executionId, variables);

It fails. I’m trying that communication since days and I can’t get out of this.

Should I use API Rest? Can you give me a clear example of your solution?
I would really appreciate it and every little help you can give me.

Riccardo

Hi Riccardo,

you can use the Java Message Api for the communication. Please have a look at the reference guide.

For example:

runtimeService.createMessageCorrelation("rispostaProposta")
  .setVariables(variables)
  .correlateWithResult();

I guess that you use a wrong execution id in your example.

Best regards,
Philipp

First of all thank you for your reply Philipp!

That’s not totally clear to me.
I tried a variety of solutions, similar or not to yours. But I don’t understand why you didn’t mention at all a reference to an execution id to your createMessageCorrelation() method.

Your assumption of the possible error is right, in fact I’m stuck to this message error:

An error happened while submitting the task form: Cannot submit task form a9838314-6230-11e7-8483-e4ce8f2e3dac: Execution with id 'a983aa2d-6230-11e7-8483-e4ce8f2e3dac' does not have a subscription to a message event with name 'rispostaProposta': eventSubscriptions is empty

I clearly understand the error, but I tried a lot of solutions, like trying both executionId and processInstanceId in different methods calls to awake a waiting intermediate catch event or a message task.

as you can see from the script.

I tried also your solution and this right here:
runtimeService.createMessageCorrelation("rispostaProposta").setVariables(variables).processInstanceId(processInstanceId).correlateWithResult();
But it’s always the same error.

I specify that I call this method from the Answer To Client task, just before finish the home holder process. As I read in the reference guide it serve to notify the process that a waiting execution has to continue. But it always retrieves an error. Maybe should I call it in the process I want to awake when I’ll receive an answer?

Best regards to you,
Riccardo