7.8. カスタム Camel コンテキストの設定
Camel Spring Boot auto-configuration によって作成された CamelContext Bean でオペレーションを実行するには、Spring コンテキストで CamelContextConfiguration インスタンスを登録します。
手順
以下のように、Spring コンテキストで
CamelContextConfigurationのインスタンスを登録します。@Configuration public class MyAppConfig { ... @Bean CamelContextConfiguration contextConfiguration() { return new CamelContextConfiguration() { @Override void beforeApplicationStart(CamelContext context) { // your custom configuration goes here } }; } }
Spring コンテキストの開始前に CamelContextConfiguration および beforeApplicationStart(CamelContext) メソッドが呼び出され、このコールバックに渡された CamelContext インスタンスは完全に自動設定されます。複数のインスタンスの CamelContextConfiguration を Spring コンテキストに追加でき、すべてが実行されます。