Fixed double rulesave + fine tune the stop of the routes that caused 100 record validation not to end.

This commit is contained in:
Katerina 2024-05-17 12:53:28 +03:00
parent 88bd430801
commit 0d363085b6
1 changed files with 16 additions and 7 deletions

View File

@ -15,7 +15,6 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.TypeConversionException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.engine.DefaultShutdownStrategy;
import org.apache.http.client.ClientProtocolException;
import java.net.UnknownHostException;
@ -73,9 +72,8 @@ public class FairOaiPmhRoute2 extends RouteBuilder {
String date = new Date().toString();
// Access the DefaultShutdownStrategy
DefaultShutdownStrategy shutdownStrategy = (DefaultShutdownStrategy) getContext().getShutdownStrategy();
// Set the shutdown timeout in milliseconds (e.g., 10 seconds)
shutdownStrategy.setTimeout(1);
/* DefaultShutdownStrategy shutdownStrategy = (DefaultShutdownStrategy) getContext().getShutdownStrategy();
shutdownStrategy.setTimeout(1);*/
onException(TypeConversionException.class)
.process(new ExceptionProcessor(validationJob))
@ -126,7 +124,6 @@ public class FairOaiPmhRoute2 extends RouteBuilder {
.multicast().parallelProcessing()
.to("direct:guidelinesProcessor")
.to("direct:fairProcessor")
.to("controlbus:route?routeId=1&action=stop&async=true")
.endChoice()
.otherwise()
.process(new ErrorProcessor(validationJob))
@ -134,29 +131,34 @@ public class FairOaiPmhRoute2 extends RouteBuilder {
.endChoice()
.end();
from("direct:guidelinesProcessor")
.routeId(routeid)
.split(xpath("//*[local-name()='record']"))
.process(new XmlProcessor(profile, validationJob, maxNumberOfRecords))
.choice()
.when(simple("${body[results]} && ${header.MyHeader} != 'stop'"))
//.log("HEADER ${header.MyHeader}")
.split(simple("${body[results]}"))
.to("jpa:" + ValidationRuleResult.class.getName() + "?usePersist=true")
.endChoice()
.end()
.choice()
.when(simple("${body[issues]} && ${header.MyHeader} != 'stop'"))
.when(simple("${body[issues]} && ${header.MyHedddader} != 'stop'"))
//.log("HEADER ${header.MyHeader}")
.split(simple("${body[issues]}"))
.to("jpa:"+ ValidationIssue.class.getName()+ "?usePersist=true")
.endChoice()
.end()
.choice()
.when(header("MyHeader").isEqualTo("stop"))
//.log("HEADER ${header.MyHeader}")
.process(new SumUpNCleanProcessor(validationJobRepository, validationResultRepository, summaryValidationJobRepository,
profile))
/*.process(new DataBaseProcessor())
.to("jpa:" + ValidationJob.class.getName() + "?useExecuteUpdate=true")//;.to("direct:saveToDatabase")*/
.to("controlbus:route?routeId="+routeid+"&action=stop&async=true")
.to("controlbus:route?routeId=1&action=stop&async=true")
.endChoice()
.end();
@ -178,14 +180,21 @@ public class FairOaiPmhRoute2 extends RouteBuilder {
.end()
.choice()
.when(header("MyHeader").isEqualTo("stop"))
.process(new SumUpNCleanProcessor(validationJobRepository, validationResultRepository, summaryValidationJobRepository,
.process(new SumUpNCleanProcessor(validationJobRepository, validationResultRepository, summaryValidationJobRepository,
fairProfile))
/*.process(new DataBaseProcessor())
.to("jpa:" + ValidationJob.class.getName() + "?useExecuteUpdate=true")//;.to("direct:saveToDatabase")*/
.to("controlbus:route?routeId="+routeid2+"&action=stop&async=true")
.to("controlbus:route?routeId=1&action=stop&async=true")
.endChoice()
.end();
/*
from("direct:afterMulticast")
.log("All processes completed")
.to("controlbus:route?routeId=1&action=stop&async=true");
*/
/*
from("direct:saveToDatabase")
.routeId(routeid2)