Auditing case management executions with Kafka and Red Hat Process Automation Manager — KIE Community

private void pushToKafka(CaseDefinition caseDefinition) {
try {
Future<RecordMetadata> out = producer.send(new ProducerRecord<String,
String>("case_events", caseDefinition.getCaseId(), new ObjectMapper().writeValueAsString(caseDefinition)));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
@Override
public void afterCaseStarted(CaseStartEvent event) {
CaseDefinition caseDefinition = new CaseDefinition(event.getCaseId(),"Case Started",null,null, new Date());
pushToKafka(caseDefinition);
}
@Override
public void finalize() {
System.out.println("case listener clean up");
producer.flush();
producer.close();}@Override
public void afterCaseDataAdded(CaseDataEvent event) {
CaseDefinition caseDefinition = new CaseDefinition(event.getCaseId(),"Case Data Added",event.getData(),null, new Date());
pushToKafka(caseDefinition);
};
@Override
public void afterCaseDataRemoved(CaseDataEvent event) {
CaseDefinition caseDefinition = new CaseDefinition(event.getCaseId(),"Case Data Removed",event.getData(),null, new Date());
pushToKafka(caseDefinition);
};
@Override
public void afterCaseClosed(CaseCloseEvent event) {
CaseDefinition caseDefinition = new CaseDefinition(event.getCaseId(),"Case Closed",null,null, new Date());
pushToKafka(caseDefinition);
};
@Override
public void afterCaseCommentAdded(CaseCommentEvent event) {
CaseComment caseComment = new CaseComment(event.getComment().getComment(),event.getComment().getAuthor());
CaseDefinition caseDefinition = new CaseDefinition(event.getCaseId(),"Comments Added",null,caseComment,new Date());
pushToKafka(caseDefinition);
};
@Override
public void afterCaseReopen(CaseReopenEvent event) {
CaseDefinition caseDefinition = new CaseDefinition(event.getCaseId(),"Case Reopened",null,null, new Date());
pushToKafka(caseDefinition);
}
mvn quarkus:dev

--

--

--

Sadhana is a Principal Solutions Architect at Red Hat. She has extensive experience in creating solutions for Banking and Insurance customers across the globe.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sadhana Nandakumar

Sadhana Nandakumar

Sadhana is a Principal Solutions Architect at Red Hat. She has extensive experience in creating solutions for Banking and Insurance customers across the globe.

More from Medium

AzureDevOps- Automated Testing using Azure Storage with Azurite

Access AWS s3 bucket files and integration with the Test framework

Creating Helm Chart With Kubernetes()

Robot Framework: Stairway to hassle-free test automation