-
Task
-
Resolution: Done
-
Major
-
None
-
None
-
None
-
2020 Week 34-36 (from Aug 17), 2020 Week 37-39 (from Sep 7)
Consumer and Producer logic is largely constant; eg.:
@org.eclipse.microprofile.reactive.messaging.Incoming("visasrejected") public void consume(String payload) { final String trigger = "visasrejected"; try { if (useCloudEvents.orElse(true)) { final TravelsMessageDataEvent_3 eventData = json.readValue(payload, TravelsMessageDataEvent_3.class); final TravelsModel model = new TravelsModel(); model.setVisaApplication(eventData.getData()); org.kie.kogito.services.uow.UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> { if (eventData.getKogitoReferenceId() != null) { LOGGER.debug("Received message with reference id '{}' going to use it to send signal '{}'", eventData.getKogitoReferenceId(), trigger); process.instances().findById(eventData.getKogitoReferenceId()).ifPresent(pi -> pi.send(Sig.of("Message-" + trigger, eventData.getData(), eventData.getKogitoProcessinstanceId()))); } else { LOGGER.debug("Received message without reference id, staring new process instance with trigger '{}'", trigger); ProcessInstance<TravelsModel> pi = process.createInstance(model); if (eventData.getKogitoStartFromNode() != null) { pi.startFrom(eventData.getKogitoStartFromNode(), eventData.getKogitoProcessinstanceId()); } else { pi.start(trigger, eventData.getKogitoProcessinstanceId()); } } return null; }); } else { final org.acme.travels.VisaApplication eventData = json.readValue(payload, org.acme.travels.VisaApplication.class); final TravelsModel model = new TravelsModel(); model.setVisaApplication(eventData); org.kie.kogito.services.uow.UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> { LOGGER.debug("Received message without reference id, staring new process instance with trigger '{}'", trigger); ProcessInstance<TravelsModel> pi = process.createInstance(model); pi.start(trigger, null); return null; }); } } catch (Exception e) { LOGGER.error("Error when consuming message for process {}", process.id(), e); } }
1) Move all the common logic to an abstract class
2) possibly refactor conditional logic (is cloud event?) to compile time-only (i.e. use a different abstract class)
- is incorporated by
-
KOGITO-2455 Rework Kogito code generation for scaffolding (processes)
- Resolved