java - apache Camel 在路由内多线程

标签 java multithreading spring-camel

我有以下路线:

    @Override
public void configure() throws Exception {
    String overviewRoute = this.routingProperties.getReportingRoute(OverviewtRouteConstants.OVERVIEW);

    this.from(overviewRoute).routeId(overviewRoute).threads(1, 100).choice()
            .when(this.simple(BODY_GRAPH_NAME + GraphConstants.OVERVIEW_OPEN_LANE + "'"))
            .to(this.routingProperties.getReportingRoute(OVERVIEW_OPENLANES_TO))
            .when(this.simple(BODY_GRAPH_NAME + GraphConstants.OVERVIEW_BELT_DOWNTIME + "'"))
            .to(this.routingProperties.getReportingRoute(OVERVIEW_BELTDOWNTIME_TO))
            .when(this.simple(BODY_GRAPH_NAME + GraphConstants.OVERVIEW_LUGGAGE_THROUGHPUT + "'"))
            .to(this.routingProperties.getReportingRoute(OVERVIEW_LUGGAGETHROUGHPUT_TO))
            .when(this.simple(BODY_GRAPH_NAME + GraphConstants.OVERVIEW_LANE_UTILIZATION + "'"))
            .to(this.routingProperties.getReportingRoute(OVERVIEW_LUGGAGETHROUGHPUT_TO))
            .when(this.simple(BODY_GRAPH_NAME + GraphConstants.OVERVIEW_LUGGAGE_SCANNED + "'"))
            .to(this.routingProperties.getReportingRoute(OVERVIEW_LUGGAGESCANNED_TO));
}

休息服务端点:
import javax.ws.rs.core.Response;

import org.springframework.stereotype.Service;
@Service(SERVICE_NAME)
public class OverviewServicesImpl extends BaseServices implements OverviewServices {

@Override
public Response overview(OverviewSearchDTO dto) {
    return this.executeRouting(OverviewtRouteConstants.OVERVIEW, dto);
}

}

语境 :
主路由概述Route是从ws REST端点调用的。其他路由根据when子句调用。

我的前端多次并行调用主路由。

我所看到的:
在“choice”子句中定义的所有路由都被顺序调用(一旦前一个路由完成,将调用下一个路由)。

我想要的是:
我希望必须在一次ws调用完成后立即调用choice子句中定义的路由,而不是在上一次调用完成后立即调用。

我尝试过的是:
Apache 色达
Spring Scope:@Scope(BeanDefinition.SCOPE_PROTOTYPE)

最佳答案

听起来所有.when子句都返回True,因此它遵循所有选择。我不确定.when子句中的部分是否为实际比较?我是否想念您如何进行比较以检查消息的一部分以在基于上下文的路由器中进行比较和路由?

关于java - apache Camel 在路由内多线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52005761/

相关文章:

android - 从另一个类中的线程更新 Android UI

java - 使用tomcat和spring进行异步http请求处理

c++ - 使用 moveToThread 时是否需要锁定

java - 如何使用 apache Camel 使用附加字段丰富 csv 内容数据并使用管道作为分隔符转换为文本文件

java - 注册 Apache Camel 处理器的监听器

java - Spring Security如何在用户注册时为用户设置角色

java - JFreeChart Boxplot Outlier 和 Farout 外观

java - Apache DateUtils : parsing a date with multiple patterns

java - 如何为 HK2 中的服务创建代理

java - 如何为camel-https4配置trustStore