将apache camel配置转换为spring java配置

将apache camel配置转换为spring java配置,spring,spring-boot,apache-camel,Spring,Spring Boot,Apache Camel,我们正在将当前的spring项目转换为springboot,同时将所有springbean从xml转换为基于java配置的 我无法将camel-xml配置转换为基于java的配置 目前,我们指定了驼峰配置、路由和端点,下面是一个示例 <camel:camelContext id="camelClient"> <camel:template id="camelTemplate"/> </camel:camelContext>

我们正在将当前的spring项目转换为springboot,同时将所有springbean从xml转换为基于java配置的

我无法将camel-xml配置转换为基于java的配置

目前,我们指定了驼峰配置、路由和端点,下面是一个示例

    <camel:camelContext id="camelClient">
        <camel:template id="camelTemplate"/>
    </camel:camelContext>


        <template id="camelTemplate"/>
如何将camel配置从xml转换为基于java的配置


我已经按照中指定的说明进行了操作,但由于我不熟悉Camel,所以很难理解。

您可以将Spring Java config与Apache Camel XML config混合搭配使用。我怀疑你为什么要做这种转换

这就是说,如果你看一下,你会发现有一个例子可以与之合作

你也可以看看样品。下面是该示例中经过修改的RouteBuilder:

@Component
public class MySpringBootRouter extends RouteBuilder {

    @Override
    public void configure() {

        Context context = getContext();
        MyEndpoint ep = context.getEndpoint("someURI", MyEndpoint.class);

        from(ep)
            .transform().simple("ref:myBean")
            .to("log:out");
    }
}

更新:我修改了代码段以显示直接获取端点。您可以在中获取更多信息。我不确定这种方法有多普遍。当我定期使用Camel时,端点是通过其URI值以声明方式配置的。我认为我从来没有在我的Camel XML或Java代码中明确定义过端点。我确信它有一些使用案例,但仅通过URI进行配置可能会更简单。

我正在将项目转换为spring boot,转换驼峰路线和端点也是如此。我看过驼峰弹簧靴的例子,大多数都有关于如何创建路线的例子,但没有一个有关于创建终点的例子。您提供的示例演示了如何创建路由,能否提供如何以非xml方式创建端点的示例
        <route>
            <from ref="directSmsNotification"/>
            <to uri="bean:messengerService?method=sendSmsMessage"/>
        </route>
smsEndpoint = _camelContext.getEndpoint("directSmsNotification");
@Component
public class MySpringBootRouter extends RouteBuilder {

    @Override
    public void configure() {

        Context context = getContext();
        MyEndpoint ep = context.getEndpoint("someURI", MyEndpoint.class);

        from(ep)
            .transform().simple("ref:myBean")
            .to("log:out");
    }
}