Camel route shutdown during Day light Savings time

Viewed 118

Below are my camel routes to send periodic messages and forward messages in queue to endpoint.

Event Route:

from("activemq:Queue.External?cacheLevelName=CACHE_CONSUMER&transacted=true")
            .routeId("EventRoute")
            .autoStartup(false)
            .filter(messageFilter)
            .process(eventTransformer)
            .setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST))
            .setHeader(Exchange.ACCEPT_CONTENT_TYPE, constant("application/xml"))
            .setProperty("eventEndpoint", constant(eventEndpoint))
            .to(eventUri)
            .process(eventResponse);

Periodic message route:

from("timer:monitor?fixedRate=true&period=" + (periodicMessageInterval() * 1000))
            .routeId("periodicMessageRoute")
            .autoStartup(false)
            .process(periodicMessageTransformer)
            .setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST))
            .setHeader(Exchange.ACCEPT_CONTENT_TYPE, constant("application/xml"))
            .doTry()
            .to(periodicMessageUri)
            .process(periodicMessageResponse)
            .doCatch(Exception.class)
            .log(LoggingLevel.DEBUG, "Error response received: ${body}");

Route initialization for periodic message detection

builder.from("activemq:topic:Topic.Heartbeat?concurrentConsumers=1&maxConcurrentConsumers=1")
            .routeId("periodic")
            .log(LoggingLevel.DEBUG, "Periodic Message Received: ${id}")
            .process(this);

    builder.from("timer:monitor?fixedRate=true&period=" + monitoringIntervalInMilliseconds)
            .routeId("timer")
            .log(LoggingLevel.DEBUG, "Checking periodic message reception")
            .process(exchange -> exchange.getIn().setBody(check()))
            .choice().when(builder.body(Boolean.class)).to("direct:stopActiveMqRoutes")
            .otherwise().to("direct:startActiveMqRoutes").end();


    ProcessorDefinition routeDefinitionStop = builder.from("direct:stopActiveMqRoutes");
    for (final String routeId : routeIds) {
        routeDefinitionStop = routeDefinitionStop
                .to("controlbus:route?routeId=" + routeId + "&action=status")
                .choice().when(builder.body().isNotEqualTo("Stopped"))
                .log(LoggingLevel.INFO, "Stopping route execution: " + routeId)
                .to("controlbus:route?routeId=" + routeId + "&action=stop&async=true")
                .end();
    }
    routeDefinitionStop.end();

    ProcessorDefinition routeDefinitionStart = builder.from("direct:startActiveMqRoutes");
    for (final String routeId : routeIds) {
        routeDefinitionStart = routeDefinitionStart
                .to("controlbus:route?routeId=" + routeId + "&action=status")
                .choice().when(builder.body().isNotEqualTo("Started"))
                .log(LoggingLevel.INFO, "Starting route execution: " + routeId)
                .to("controlbus:route?routeId=" + routeId + "&action=start&async=true")
                .end();
    }
    routeDefinitionStart.end();

Both the routes stopped during the day light savings time for 1 hour and the routes started automatically after 1 hour. Is it because of the Timer component in JDK that caused this issue?

Error log:

2017-11-05 01:01:13,921 INFO  [route2] Stopping route execution: EventRoute
2017-11-05 01:01:13,921 INFO  [route2] Stopping route execution: periodicMessageRoute
2017-11-05 01:01:26,671 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] Route: EventRoute shutdown complete, was consuming from: activemq://Queue.External?cacheLevelName=CACHE_CONSUMER&transacted=true
2017-11-05 01:01:26,672 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] Graceful shutdown of 1 routes completed in 22 seconds
2017-11-05 01:01:26,673 INFO  [org.apache.camel.spring.SpringCamelContext] Route: EventRoute is stopped, was consuming from: activemq://Queue.External?cacheLevelName=CACHE_CONSUMER&transacted=true
2017-11-05 01:01:26,675 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] Starting to graceful shutdown 1 routes (timeout 300 seconds)
2017-11-05 01:01:26,676 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] Route: periodicMessageRoute shutdown complete, was consuming from: timer://monitor?fixedRate=true&period=30000
2017-11-05 01:01:26,680 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] Graceful shutdown of 1 routes completed in 0 seconds
2017-11-05 01:01:26,681 INFO  [org.apache.camel.spring.SpringCamelContext] Route: periodicMessageRoute is stopped, was consuming from: timer://monitor?fixedRate=true&period=30000
2017-11-05 01:01:26,681 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] Starting to graceful shutdown 1 routes (timeout 300 seconds)
2017-11-05 01:01:26,681 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] Route: EventRoute shutdown complete, was consuming from: activemq://Queue.External?cacheLevelName=CACHE_CONSUMER&transacted=true
2017-11-05 01:01:26,681 INFO  [org.apache.camel.impl.DefaultShutdownStrategy] Graceful shutdown of 1 routes completed in 0 seconds
2017-11-05 01:00:03,921 INFO  [route3] Starting route execution: EventRoute
2017-11-05 01:00:03,924 INFO  [route3] Starting route execution: periodicMessageRoute
2017-11-05 01:00:03,943 INFO  [org.apache.camel.spring.SpringCamelContext] Route: EventRoute started and consuming from: activemq://Queue.External?cacheLevelName=CACHE_CONSUMER&transacted=true
0 Answers
Related