Apache camel Apache Camel多线程限制错误

Apache camel Apache Camel多线程限制错误,apache-camel,Apache Camel,当我将多线程请求发送到带有节流的路由时,有时会出现NPE异常。若路线并没有节流,一切都很好。在多线程环境中使用节流时,是否需要在某些地方进行同步化 路线以成功告终: from("direct:start").log("executed ${body}").to("mock:result"); 有时,带有节流端的管线带有NPE: from("direct:start").throttle(method(ThrottlingTester.class, "getMessagesPerSecond")

当我将多线程请求发送到带有节流的路由时,有时会出现NPE异常。若路线并没有节流,一切都很好。在多线程环境中使用节流时,是否需要在某些地方进行同步化

路线以成功告终:

from("direct:start").log("executed ${body}").to("mock:result");
有时,带有节流端的管线带有NPE:

from("direct:start").throttle(method(ThrottlingTester.class, "getMessagesPerSecond")).timePeriodMillis(1000).rejectExecution(true).log("executed ${body}").to("mock:result");
代码发送请求:

MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
resultEndpoint.expectedMessageCount(6);
resultEndpoint.setResultWaitTime(3000);
for (int i = 0; i < 3; i++) {
    new Thread(new Runnable() {
@Override
public void run() {
    template.sendBody("direct:start", "<test1> </test1>");
}
}).start();
}
for (int i = 0; i < 5; i++) {
    new Thread(new Runnable() {
@Override
public void run() {
    template.sendBody("direct:start", "<test2> </test2>");
}
}).start();
}
resultEndpoint.assertIsSatisfied();
错误:

Caused by: java.lang.NullPointerException
    at org.apache.camel.processor.Throttler$TimeSlot.access$002(Throttler.java:158)
    at org.apache.camel.processor.Throttler.calculateDelay(Throttler.java:123)
    at org.apache.camel.processor.DelayProcessorSupport.process(DelayProcessorSupport.java:156)

使用Camel版本2.15.3

您使用什么版本的Camel?使用版本2.15.3尝试升级到最新的2.15.x或2.16.x,其中节流器在并发性方面得到了改进。我会尝试一下,谢谢。您使用什么版本的Camel?使用版本2.15.3尝试升级到最新的2.15.x,或者在2.16.x中,节流器在并发性方面得到了改进。我会尝试一下,谢谢。
Caused by: java.lang.NullPointerException
    at org.apache.camel.processor.Throttler$TimeSlot.access$002(Throttler.java:158)
    at org.apache.camel.processor.Throttler.calculateDelay(Throttler.java:123)
    at org.apache.camel.processor.DelayProcessorSupport.process(DelayProcessorSupport.java:156)