Java 类org.apache.camel.model.ThrottleDefinition 实例源码

项目:syndesis    文件:ThrottleHandler.java   
@Override
public Optional<ProcessorDefinition> handle(Throttle step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) {
  ThrottleDefinition throttle = route.throttle(step.getMaximumRequests());
  Long period = step.getPeriodMillis();
  if (period != null) {
    throttle.timePeriodMillis(period);
  }
  return routeBuilder.addSteps(throttle, step.getSteps());
}
项目:syndesis-integration-runtime    文件:ThrottleHandler.java   
@Override
public ProcessorDefinition handle(Throttle step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) {
  ThrottleDefinition throttle = route.throttle(step.getMaximumRequests());
  Long period = step.getPeriodMillis();
  if (period != null) {
    throttle.timePeriodMillis(period);
  }
  return routeBuilder.addSteps(throttle, step.getSteps());
}
项目:omakase    文件:TaskStatusQueueRouteTest.java   
@Test
public void shouldConfigureRouteWithoutThrottling() throws Exception {
    route.throttleMaxPerPeriod = -1;
    route.periodInMs = 100;
    route.configure();
    RouteDefinition routeDefinition = route.getRouteCollection().getRoutes().get(0);
    assertThat(routeDefinition.getOutputs().stream().filter(processorDefinition -> processorDefinition instanceof ThrottleDefinition).findFirst()).isEmpty();
}
项目:omakase    文件:TaskStatusQueueRouteTest.java   
@Test
public void shouldConfigureRouteWithThrottling() throws Exception {
    route.throttleMaxPerPeriod = 10;
    route.periodInMs = 100;
    route.configure();
    RouteDefinition routeDefinition = route.getRouteCollection().getRoutes().get(0);
    ThrottleDefinition throttleDefinition =
            (ThrottleDefinition) routeDefinition.getOutputs().stream().filter(processorDefinition -> processorDefinition instanceof ThrottleDefinition).findFirst().get();
    assertThat(throttleDefinition.getExpression().getExpressionValue().toString()).isEqualTo("10");
    assertThat(throttleDefinition.getTimePeriodMillis()).isEqualTo(100);
}
项目:Camel    文件:CamelGroovyMethods.java   
public static ThrottleDefinition throttle(ProcessorDefinition<?> self, Closure<?> expression) {
    return self.throttle(toExpression(expression));
}