Apache camel 基于查询参数限制驼峰请求

Apache camel 基于查询参数限制驼峰请求,apache-camel,Apache Camel,我有一条骆驼路线,如下所示:- 来自(“码头:http://localhost:8888/orchestratorservice过程(处理器) from(“direct:setStatusToReadyToShip”)。到(“bean:orderHelper?method=setStatusToReadyToShip”) 我已经看过了。但是有没有一种方法可以根据查询/头参数获得速率限制/限制(例如,如果在请求中设置了debug=1,那么我们希望将请求限制为10 req/sec)。是的,这是可行的

我有一条骆驼路线,如下所示:-

来自(“码头:http://localhost:8888/orchestratorservice过程(处理器)

from(“direct:setStatusToReadyToShip”)。到(“bean:orderHelper?method=setStatusToReadyToShip”)


我已经看过了。但是有没有一种方法可以根据查询/头参数获得速率限制/限制(例如,如果在请求中设置了debug=1,那么我们希望将请求限制为10 req/sec)。

是的,这是可行的,但比您最初假设的要复杂一些。从技术上讲,这是一个重复的问题,因此我只提供以下链接:


基本上,简短的版本是您必须利用camel设置的jmx调用。在Camel 2.16+中,这要容易得多。然而,骆驼2.15中也列出了一个不太方便的解决方法。祝你的项目好运

是的,它是可以做到的,但比您最初设想的要复杂一些。从技术上讲,这是一个重复的问题,因此我只提供以下链接:


基本上,简短的版本是您必须利用camel设置的jmx调用。在Camel 2.16+中,这要容易得多。然而,骆驼2.15中也列出了一个不太方便的解决方法。祝你的项目好运

我能够用谓词来解决它。以下代码适用于我:-

Predicate isDebug = header("debug").isEqualTo("true");
from("jetty:http://localhost:8888/orchestratorservice")     
.choice()
    .when(isDebug).throttle(5).timePeriodMillis(1000).rejectExecution(true).process(processor)
.endChoice()
.otherwise()
   .process(processor);

我可以用谓词来解决它。以下代码适用于我:-

Predicate isDebug = header("debug").isEqualTo("true");
from("jetty:http://localhost:8888/orchestratorservice")     
.choice()
    .when(isDebug).throttle(5).timePeriodMillis(1000).rejectExecution(true).process(processor)
.endChoice()
.otherwise()
   .process(processor);