noi.m
noi.m

Reputation: 3132

Camel context not starting in hello world app

I am attempting to run camel within spring. Below are the files i have..

  1. POM xml file which have relevant dependencies.
<properties>
  <spring.version>3.2.11.RELEASE</spring.version>
  <camel.version>2.14.1</camel.version>
</properties>

<?xml version="1.0" encoding="UTF-8"?>
<dependencies>
   <!-- camel core -->
   <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
      <version>${camel.version}</version>
   </dependency>
   <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring</artifactId>
      <version>${camel.version}</version>
   </dependency>
   <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-metrics</artifactId>
      <version>${camel-version}</version>
   </dependency>
   <!-- Spring 3 dependencies -->
   <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring.version}</version>
   </dependency>
   <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
   </dependency>
</dependencies>
  1. Main context file (main-context.xml).
<camel:camelContext trace="false" id="mc-service-camel-context" threadNamePattern="Camel (#camelId#) thread ##counter# - #name#">
<camel:contextScan/>
</camel:camelContext>
  1. A route that looks like this
@Component
public class MyRoute extends RouteBuilder {

@Override
public void configure() throws Exception {
  from("timer://runOnce?repeatCount=1&delay=5000")
  .log("Hello World!!")
  .end();
}

}
  1. And finally a main class that looks like this.
public static void main(String[] args) throws InterruptedException {

  AbstractXmlApplicationContext appContext = new ClassPathXmlApplicationContext("main-context.xml");
Thread.sleep(100000);

}

Issue is i don't see the log "Hello World". Could someone give me some feedback on what i am missing..

Upvotes: 1

Views: 1540

Answers (1)

noi.m
noi.m

Reputation: 3132

I had to enable Component scanning.

<context:annotation-config/>
<context:component-scan base-package="com.mycompany.app*" />

Upvotes: 1

Related Questions