Creating boundary event with errorEventDefinition programmatically using Camunda BPMN2.0 API.

618 views
Skip to first unread message

bha...@gmail.com

unread,
Jul 4, 2014, 2:07:29 AM7/4/14
to camunda-...@googlegroups.com
Hello,

I am working on a module, which creates a dynamic workflow and runs it using Activiti Engine. I am using "camunda bpmn2.0 - (7.1.0-Final)" to create the bpmn20.xml file dynamically.

I started my reading from this section, http://docs.camunda.org/latest/guides/user-guide/#bpmn-model-api

And My requirement is something like this

start --> subprocess [ subStart --> servicetask --> subEnd ] --> end
error-boundary-Event
|
|
|--------> errorHandler(serviceTask) --> end2

Here's the code snippet where I am trying to create the boundary event

BoundaryEvent errorBoundaryEvent = createElement(process, "boundary-event", BoundaryEvent.class);
errorBoundaryEvent.setAttachedTo(subProcess);
EventDefinition errorEvent = createElement(process, "error", EventDefinition.class);
errorBoundaryEvent.getEventDefinitions().add(errorEvent);

here,

process, is the Main process
subProcess, is the sub process

This is giving me the following error,

org.camunda.bpm.model.xml.impl.util.ModelTypeException: Model element type eventDefinition is abstract and no instances can be created.
at org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl.createModelElementInstance(ModelElementTypeImpl.java:98)
at org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl.newInstance(ModelElementTypeImpl.java:77)
at org.camunda.bpm.model.xml.impl.type.ModelElementTypeImpl.newInstance(ModelElementTypeImpl.java:72)
at org.camunda.bpm.model.xml.impl.ModelInstanceImpl.newInstance(ModelInstanceImpl.java:79)
at org.camunda.bpm.model.xml.impl.ModelInstanceImpl.newInstance(ModelInstanceImpl.java:71)

Can anyone please guide me to any example code, having such error handling boundary event?

Sebastian Menski

unread,
Jul 4, 2014, 3:40:08 AM7/4/14
to camunda-...@googlegroups.com, bha...@gmail.com
Hi,

the version 7.1.0-Final of the camunda BPMN model API only supports Message Event Definitions. The next
major release 7.2.0-Final will support all event definitions. The error event definition was already implemented 
with ticket CAM-2275.

If you already want to use the new event definitions you can download the current snapshot of the model

Then you can use it as expected:

SubProcess subprocess = modelInstance.getModelElementById("subprocess");
BoundaryEvent boundaryEvent = modelInstance.newInstance(BoundaryEvent.class);
boundaryEvent
.setAttachedTo(subprocess); process.addChildElement(boundaryEvent);

ErrorEventDefinition errorEventDefinition = modelInstance.newInstance(ErrorEventDefinition.class);
boundaryEvent
.getEventDefinitions().add(errorEventDefinition);

Cheers,
Sebastian
Message has been deleted

bha...@gmail.com

unread,
Jul 4, 2014, 4:04:16 AM7/4/14
to camunda-...@googlegroups.com, bha...@gmail.com
Thank you for the quick reply :), I used 7.2.0-SNAPSHOT and it worked! Can you please tell me when will the final release for the version may get shipped?

Also, I really like using Camunda BPMN2.0 model API, as compared to API's provided by other engine providers.

Sebastian Menski

unread,
Jul 4, 2014, 4:19:04 AM7/4/14
to camunda-...@googlegroups.com, bha...@gmail.com
Hi,

great that it worked for you and thanks for the positive feedback.

The next alpha release 7.2.0-alpha3 is planned to be released in two weeks. So you won't have to use a snapshot anymore. The final 7.2.0-Final
release has currently no fixed release date but is planned for the fall of this year.

Cheers,
Sebastian
Reply all
Reply to author
Forward
0 new messages