activity.setAsyncBefore(isAsyncBefore);
activity.setAsyncAfter(isAsyncAfter);
if(isAsyncBefore) {
MessageJobDeclaration messageJobDeclaration = new AsyncBeforeMessageJobDeclaration();
messageJobDeclaration.setExclusive(exclusive);
messageJobDeclaration.setActivityId(activity.getId());
addMessageJobDeclarationToActivity(messageJobDeclaration, activity);
addJobDeclarationToProcessDefinition(messageJobDeclaration, activity.getProcessDefinition());
}
if(isAsyncAfter) {
MessageJobDeclaration messageJobDeclaration = new AsyncAfterMessageJobDeclaration();
messageJobDeclaration.setExclusive(exclusive);
messageJobDeclaration.setActivityId(activity.getId());
addMessageJobDeclarationToActivity(messageJobDeclaration, activity);
addJobDeclarationToProcessDefinition(messageJobDeclaration, activity.getProcessDefinition());
}