How to map process variables to task parameters in jBPM5?
Issue
- How can I code a human task client to modify an object from the process instance?
To be precise here is what I want to achieve.
- I have an object from class
OrderMsg, that has a bunch of properties. OrderMsgis set as a parameter in the process.- The process stops at a human task.
- A task client reads the human task, and needs to set the
cancelledproperty of theOrderMsgobject totrue, so that the next task in the process can see that this order is cancelled.
How can that be done? I am trying code in the task client similar to the following, but it does not work, the cancelled property is still false in the next task of the process.
TaskClient client = new TaskClient(new MinaTaskClientConnector("client 1", new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
client.connect("127.0.0.1", 9123);
OrderMsg orderMsg = this.getOrderMsgFromTask(client, taskId); // uses GetResponseHandler
orderMsg.processControl.setCancelledInvoice(true);
SetDocumentResponseHandler setResponseHandler = new BlockingSetContentResponseHandler();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(bos);
out.writeObject(orderMsg);
Content content = new Content();
content.setContent(bos.toByteArray());
out.close();
bos.close();
System.out.println("setting document content for task id " + taskId);
client.setDocumentContent(taskId, content, setResponseHandler);
this.startTask(taskId);
this.completeTask(taskId);
Environment
- JBoss Enterprise Business Rules Management System Platform (BRMS)
- 5.3.x
- jBPM
- 5.2
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
