2016-08-17 10 views
1

springCamelContextにはcamel-spring jarを使用しています。ラクダの文脈を始めると、5分間(デフォルトの時間)実行されます。私はつまり、いくつかの特定の時間Camelコンテキストを永久に実行できるようにする

try { 
      camelContext.start(); 
      Thread.sleep(50 * 60 * 1000); 
      camelContext.stop(); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 

のための私のスレッドの睡眠を作ることができますが、私はこのアプリケーションが展開されようとしているので、私のcamelContextはFOREVER実行しているしたいとそれはKAFKAサーバからのメッセージをリッスンします。私はクラスが

org.apache.camel.spring.Main 

あります知っているしかし、私は他の方法があるかどうかわからspringCamelContextとか、それを構成する方法を知りません。おかげ

アップデート:私はcamelContext.stop()を削除しても、コンテキストはいつか後に停止し、私は次のログを取得:

[Thread-1] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel 2.17.2 (CamelContext: camel-1) is shutting down 
    [Thread-1] INFO org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds) 
    [Camel (camel-1) thread #1 - ShutdownTask] INFO org.apache.camel.component.kafka.KafkaConsumer - Stopping Kafka consumer 
    [Camel (camel-1) thread #1 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Route: route1 shutdown complete, was consuming from: Endpoint[kafka://localhost:9092?groupId=group0&serializerClass=org.springframework.integration.kafka.serializer.avro.AvroSerializer&topic=my-topic] 
    [Thread-1] INFO org.apache.camel.impl.DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds 
    [Thread-1] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel 2.17.2 (CamelContext: camel-1) uptime 4 minutes 
    [Thread-1] INFO org.apache.camel.spring.SpringCamelContext - Apache Camel 2.17.2 (CamelContext: camel-1) is shutdown in 0.022 seconds 
+0

なぜをあなたはcontext.stop()を呼び出していますか? –

+0

@MartinFrey私は自分の質問を更新しました。 Plzは見ている。 – rishi

+0

どのようにCamelを導入していますか?私が理解するように、キャメルの文脈は長続きしており、アプリケーションが存続する限り生きようとしています。あなたは見ましたか?https://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html –

答えて

関連する問題