I have created Simple JBossFUSE spring boot application with following dependencies
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sample.fuse</groupId>
<artifactId>sample-FUSE</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>springboot-camel-restdsl-api</name>
<description>Camel SpringBoot REST API Example with REST DSL</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>sample.fuse.UrarepSpringBootApplication</start-class>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-servlet-starter</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>mq-jms-spring-boot-starter</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId>
<version>9.2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-artemis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz</artifactId>
<version>2.13.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Then I created simple RouteBuilder with following content
package sample.fuse.routebuilder;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import sample.fuse.process.*;
import javax.ws.rs.core.MediaType;
@Component
public class MyRouteBuilder extends RouteBuilder {
static Logger LOG = LoggerFactory.getLogger(MyRouteBuilder.class);
@Autowired
TestProcessor testProcessor;
@Override
public void configure() throws Exception {
from("quartz://seasonParkingProcessorCron?cron=10+*+*+*+*+?&trigger.timeZone=America/Chicago&job.name=seasonParkingProcessorCron")
.log(LoggingLevel.INFO, "seasonParkingProcessorCron job kicked off")
.process(testProcessor);
}
}
Sample processor have following content.
package sample.fuse.process;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import sample.fuse.repository.MevEhtVideoImagesRepository;
import java.util.Calendar;
@Service
@Component
public class TestProcessor implements Processor {
static Logger LOG = LoggerFactory.getLogger(TestProcessor.class);
@Autowired
Environment environment;
@Autowired
private MevEhtVideoImagesRepository mevEhtVideoImagesRepository;
public TestProcessor(){
}
@Override
public void process(Exchange exchange) throws Exception {
String body= (String) exchange.getIn().getBody();
LOG.info("TestProcessor Called with exchange: " + body);
System.out.println("AAAAAAAAAAAAAa");
exchange.getOut().setBody(body+" "+ Calendar.getInstance().getTime());
}
}
I'm expecting to call my Processor method every 10 seconds and print the log. However its giving following error on the log.
11:58:10,013 WARN [org.apache.camel.component.quartz.QuartzEndpoint] (DefaultQuartzScheduler-camel-1_Worker-1) Cannot execute Quartz Job with context: JobExecutionContext: trigger: 'Camel.seasonParkingProcessorCron job: DEFAULT.seasonParkingProcessorCron fireTime: 'Thu Dec 21 11:58:10 SGT 2023 scheduledFireTime: Thu Dec 21 11:58:10 SGT 2023 previousFireTime: 'null nextFireTime: Thu Dec 21 11:59:10 SGT 2023 isRecovering: false refireCount: 0 because processor is not started: RoundRobinLoadBalancer
Anyone else experience this kind of error?
You have to use same version of the camel-core version for the camel-quartz. But in your pom file camel-core and camel-quartz versions should be matched. Your camel-quartz dependency in pom file should be updated as following
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-quartz</artifactId>
<version>2.19.0</version>
</dependency>
Then your MyRouteBuilder class configure method content need to changed as below.
from("quartz://seasonParkingProcessorCron?cron=10+*+*+*+*+?")
.log(LoggingLevel.INFO, "seasonParkingProcessorCron job kicked off")
.process(testProcessor);
Hope this will help to resolve your issue.