HI,
Below is my code I am emitting command from a loop CommandHandler and at the end I am applying an event from that event I am trying to emmit another command as soon as I try to do that I get into a unconditional loop. Please help to suggest what am i doing wrong here.
@CommandHandler
public void handle(InitateKotaxTaxTransactionCommand initateKotaxTaxTransactionCommand) {
SAXParserFactory factory = SAXParserFactory.newInstance();
try (InputStream is = getXMLFileAsStream(xmlloadPath + initateKotaxTaxTransactionCommand.fileName)) {
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(is, itemLoaderServiceImpl);
this.individualTaxLine = itemLoaderServiceImpl.getResult();
} catch (ParserConfigurationException | SAXException | IOException e) {
e.printStackTrace();
}
this.individualTaxLine.forEach((taxLine) -> {
commandGateway.send(new GenerateChallanCommand(this.crnNo, taxLine.getPan(), taxLine.getAssessmentYear(),
taxLine.getBasicTax(), taxLine.getEduCess(), taxLine.getInterest(), taxLine.getMajorHead(),
taxLine.getMinorHead(), taxLine.getNaturePymnt(), taxLine.getOtherAmt(), taxLine.getPenalty()));
});
AggregateLifecycle.apply(new KotaxTaxTransactionInitatedEvent(initateKotaxTaxTransactionCommand.crnNo,
initateKotaxTaxTransactionCommand.fileName, this.individualTaxLine,initateKotaxTaxTransactionCommand));
}
@EventSourcingHandler
public void on(KotaxTaxTransactionInitatedEvent initateKotaxTaxTransactionCommand) {
this.crnNo = initateKotaxTaxTransactionCommand.getId();
this.status = FileStatus.TXN_INITIATED;
commandGateway.send(new MakePaymentCommand(initateKotaxTaxTransactionCommand.getId(),initateKotaxTaxTransactionCommand.individualTaxLine));
}
//Below command gets into an unconditional loop.
@CommandHandler
public void handle(MakePaymentCommand transformFileCommand) {
if(this.status == FileStatus.TXN_INITIATED) {
var totalTaxAmt = transformFileCommand.individualTaxLine.stream().filter((row)->row.isCrnGenerated()).collect(Collectors.toList()).stream().reduce(0,(subtotal,amt)->subtotal+amt.getTotalAmt(), Integer::sum);
System.out.println(“#########################”+totalTaxAmt);
}
}