Reputation: 127
i wanted to know how to start a process in JBPM 6.1.0.CR1 through REST passing a custom object.
When i start a process through jbpm-console the form is displayed to input the data. Is there a way to pass the same data through a REST call ?
My ultimate goal is to have a JMeter script fire up multiple processes in order to test the performance of the system.
Even if passing custom objects is not feasible, i would like to know whether it is possible to pass primitive types (String, Integer etc) - even then i could construct my custom object after firing the process.
I tried JBPM documentation but i cannot understand how to use query params and whether it applies in my scenario.
Upvotes: 1
Views: 2958
Reputation: 305
You need add your kjar as maven dependency in your project in order to create your custom objects created through jbpm-console. then you can pass in the map.
In order to retrieve the map with object values you need to uses
RemoteRestRuntimeEngineFactory restSessionFactory = new RemoteRestRuntimeEngineFactory(process,
new URL("http://127.0.0.1:8080/business-central"),
"username, "pass");
RuntimeEngine engine = restSessionFactory.newRuntimeEngine();
TaskService taskService = engine.getTaskService();
Task task = taskService.getTaskById(taskId);
long contentId = task.getTaskData().getDocumentContentId();
Content content = taskService.getContentById(contentId);
**((Map< String,Object >) ContentMarshallerHelper.unmarshall(content.getContent(), null));**
Upvotes: 0
Reputation: 127
The best solution i turned out with, was to analyze my custom Object to primitives and pass these over REST (as map_* query parameters). The custom Object is then created in the flow within a script task (calling kcontext.put("obj",obj) ).
This way i maintain simplicity and avoid XML / JSON marshalling that takes up more resources.
Ofcourse, in case a very complex custom object needs to be passed the solution Kris is proposing is probably better - however if your custom object is THAT complex probably you need to refactor / analyze your model more.
Upvotes: 1
Reputation: 2918
Try using the REST execution operation, there you can send XML commands, like for example a StartProcessCommand, and this can contain custom types. These custom objects will be serialized to XML using JAXB. If you use the remote Java REST client, it is using the same approach.
Upvotes: 0