2016-08-02 19 views
0

Ich bin neu zu Apache Kamel und Spring Boot. Ich schreibe eine Anwendung, wo ich eine Datei aus einem Ordner in JMS-Warteschlange übertragen muss. Aber vorher versuche ich, die Datei von einem Ordner auf einen anderen zu übertragen, was nicht passiert. Beim Ausführen der Anwendung als Spring-Boot-Anwendung wird der Eingabeordner erstellt. Wenn Sie die Datei in diesen Ordner einfügen, wird der Zielordner nicht erstellt, und die Protokollanweisungen werden ebenfalls nicht angezeigt. Dies ist, wie ich die Route hinzugefügt:Apache Kamelkopie Datei zwischen den Verzeichnissen

@SpringBootApplication 
public class CamelApplication extends FatJarRouter { 

    public static void main(String ... args) { 
     SpringApplication.run(CamelApplication.class, args); 
    } 

    @Override 
    public void configure() throws Exception { 
     from("file:input?noop=true") 
     .log("Read from the input file") 
     .to("file:destination") 
     .log("Written to output file"); 
    } 
} 

Antwort

2

sollte es funktionieren, und es funktioniert für mich, vielleicht haben Sie Ihren Arbeitsbereich in Ihrem IDE nicht aktualisiert, wenn das ist, wie Sie den Fortschritt sind zu verfolgen.

EDIT

ich jetzt sehen, was mit Ihrer Konfiguration falsch ist - Sie wahrscheinlich sofort keine Feder-boot-Starter-Web auf Ihrem Classpath haben, so ist der Hauptmechanismus nicht blockiert werden und tritt aus.

Sie sollten die Hauptmethode von CamelApplication entfernen und fügen Sie diesen Eintrag application.properties:

spring.main.sources = com.example.CamelApplication 

Oder können Sie Ihre Hauptmethode ändern CamelSpringBootApplicationController auszuführen:

@SpringBootApplication 
public class CamelApplication extends FatJarRouter { 

    public static void main(String... args) { 
     ApplicationContext applicationContext = SpringApplication.run(DemoApplication.class, args); 
     CamelSpringBootApplicationController applicationController = 
       applicationContext.getBean(CamelSpringBootApplicationController.class); 
     applicationController.run(); 
    } 

    @Override 
    public void configure() throws Exception { 
     from("file:input?noop=true") 
       .log("Read from the input file") 
       .to("file:destination") 
       .log("Written to output file"); 
    } 
} 

Alternativ können Sie hinzufügen dies zu Ihrer pom.xml, um einen eingebetteten Tomcat zum Starten und Blockieren Ihrer Hauptmethode zu zwingen:

<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-web</artifactId> 
</dependency> 
+0

Danke. Ich habe die Abhängigkeit für Spring-Boot-Starter-Web hinzugefügt und es hat funktioniert. – Megha