Pantelis Natsiavas
Pantelis Natsiavas

Reputation: 5369

jBPM - Access signal event data?

I am new to jBPM and I seem to lose something fundamental. I cannot seem to find any descent tutorial on how to make an actual process work from a developer's point of view. Therefore, I follow the official jBPM 6.1 user guide. I have setup the process shown in the screenshot enter image description here

As you can see, the process is very simple. A signal event is raised and the data given to this signal event are mapped to the IncomingData object. In the following script task, I write a message to the console and try to write the IncomingData object's testing property data content to test the handling of event's data.

I test my process using a unit test:

@Test
public void testProcess() {
    RuntimeManager manager = createRuntimeManager("workflow.bpmn");
    RuntimeEngine engine = getRuntimeEngine(null);
    KieSession ksession = engine.getKieSession();

    ProcessInstance processInstance = ksession.startProcess("testing.OA");

    IncomingData dataObject = new IncomingData();
    dataObject.testProperty = "Testing data 2";
    ksession.signalEvent("StartSignalWithData", dataObject, processInstance.getId());


    // check whether the process instance has completed successfully
    assertProcessInstanceCompleted(processInstance.getId(), ksession);

    manager.disposeRuntimeEngine(engine);
    manager.close();

}

However, all I get in the console output is the message Script task logging null. Could you please explain where am I wrong?

  1. I am pretty confident that in my unit test, I pass the event data using the right procedure as indicated here. I don't believe the problem is there...

  2. Is the problem in the modelling of the process? I have created the data object IncomingData which I believed it could hold the data of the event. EDIT:I have also mapped the signal incoming data to the respective data object (see the next screenshot). Is something wrong with that?

enter image description here

  1. Am I doing something wrong while calling the IncomingData object in the script task? Should I use the kcontext or something?

Could you by any chance point me to a tutorial for jBPM 6.1 or something?

Thank you in advance

EDIT: PS. You can find my bpmn file in this link

Upvotes: 2

Views: 3927

Answers (2)

Pantelis Natsiavas
Pantelis Natsiavas

Reputation: 5369

I found the problem. When I tried to debug more carefully, I noticed that the process' script task executes when the process starts through the call ksession.startProcess("testing.OA") before the raise of the event which is done through the ksession.signalEvent. This would naturally leed to a null IncomingData object when the process is executed.

Upvotes: 1

user4351055
user4351055

Reputation: 1

In the start event you also need to create a mapping, that will map the signal data to a variable of your choice.

Upvotes: 0

Related Questions