java - 使用Camel Main类时如何设置PropertiesComponent?

标签 java apache-camel

我正在使用 Main 类进行简单的 Java Camel 演示,并且需要为 Context 设置一个 PropertiesComponent,如下所示:

    main.enableTrace();
    main.enableHangupSupport();
    main.addRouteBuilder(new RouteBuilderDemo());

    CamelContext context = main.getOrCreateCamelContext();
    PropertiesComponent pc = new PropertiesComponent();
    pc.setLocation(“test.properties”);      
    context.addComponent("properties", pc);

当我运行时,我得到:

尚未配置现有的 PropertiesComponent,正在创建一个新的默认 PropertiesComponent,名称为:properties

我可以在不使用 Camel Main 帮助器的情况下完成此工作吗?

目前正在研究这种方法:How to add an EventNotifier to Camel using Main class standalone

最佳答案

这就是我的项目为 MainSupport 上下文绑定(bind) PropertiesComponent 的方式:

    PropertiesComponent pc = new PropertiesComponent();
    main.bind("properties", pc);

关于java - 使用Camel Main类时如何设置PropertiesComponent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32186380/

相关文章:

java - 黑莓模拟器和手机上的 DNS 错误

java - 我的程序将在几秒钟后崩溃。为什么?

java - Android - GsonRequest 返回 null

java - Camel + Groovy + Spring DSL 的奇怪行为

java - JMS 消费者阻止其他 JMSXGroups

java - Application Insights 添加 http 过滤器

java - JAVA随机圈

java - 暂停所有线程花费了 : ms warning using Threads - Android

java - 如何为 Apache Camel 路由的 Split 准备 Executor 服务,org.apache.camel.spi.ThreadPoolProfile 与 java.util.concurrent.ExecutorService

java - 如何读取具有相同文件名的多个附件