org.apache.camel.spi.RoutePolicy Java Examples

The following examples show how to use org.apache.camel.spi.RoutePolicy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlipRoutePolicyJavaDSLTest.java    From camelinaction with Apache License 2.0 6 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // create the flip route policy
            RoutePolicy policy = new FlipRoutePolicy("foo", "bar");

            // use the flip route policy in the foo route
            from("timer://foo?delay=500")
                .routeId("foo").routePolicy(policy)
                .setBody().constant("Foo message")
                .to("log:foo")
                .to("mock:foo");

            // use the flip route policy in the bar route and do NOT start
            // this route on startup
            from("timer://bar?delay=500")
                .routeId("bar").routePolicy(policy).noAutoStartup()
                .setBody().constant("Bar message")
                .to("log:bar")
                .to("mock:bar");
        }
    };
}
 
Example #2
Source File: WebhookRoutePolicyFactory.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, NamedNode route) {
    if (action != null) {
        return new WebhookRoutePolicy(camelContext, action);
    }
    return null;
}
 
Example #3
Source File: IntegrationRouteBuilder.java    From syndesis with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if given route definition has already been configured with activity tracking policies.
 * @param definition the route definition to evaluate.
 * @return true if activity tracking policies have already been configured on given route definition.
 */
private boolean isRouteDefinitionAndNoContainsConfiguredActivityTrackingPolicies(ProcessorDefinition<?> definition) {

    if (definition instanceof RouteDefinition) {
        RouteDefinition routeDefinition = (RouteDefinition) definition;
        List<RoutePolicy> routePolicies = routeDefinition.getRoutePolicies();
        if (ObjectHelper.isEmpty(routePolicies)) {
            return true;
        }

        return !activityTrackingPolicyFactories.stream().anyMatch(policyFactory -> routePolicies.stream().anyMatch(policyFactory::isInstance));
    }

    return false;
}
 
Example #4
Source File: FlipRoutePolicyJavaDSLTest.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // create the flip route policy
            RoutePolicy policy = new FlipRoutePolicy("foo", "bar");

            // use the flip route policy in the foo route
            from("timer:foo?delay=500")
                .routeId("foo").routePolicy(policy)
                .setBody().constant("Foo message")
                .to("log:foo")
                .to("mock:foo");

            // use the flip route policy in the bar route and do NOT start
            // this route on startup
            from("timer:bar?delay=500")
                .routeId("bar").routePolicy(policy).noAutoStartup()
                .setBody().constant("Bar message")
                .to("log:bar")
                .to("mock:bar");
        }
    };
}
 
Example #5
Source File: FlowActivityTrackingPolicyFactory.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
public RoutePolicy createRoutePolicy(String flowId) {
    return new FlowActivityTrackingPolicy(tracker);
}
 
Example #6
Source File: FlowActivityTrackingPolicyFactory.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isInstance(RoutePolicy routePolicy) {
    return FlowActivityTrackingPolicy.class.isInstance(routePolicy);
}
 
Example #7
Source File: IntegrationActivityTrackingPolicyFactory.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
public RoutePolicy createRoutePolicy(String flowId) {
    return new IntegrationActivityTrackingPolicy(tracker);
}
 
Example #8
Source File: IntegrationActivityTrackingPolicyFactory.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isInstance(RoutePolicy routePolicy) {
    return IntegrationActivityTrackingPolicy.class.isInstance(routePolicy);
}
 
Example #9
Source File: TracingActivityTrackingPolicyFactory.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
public RoutePolicy createRoutePolicy(String flowId) {
    return new TracingActivityTrackingPolicy(tracer, flowId);
}
 
Example #10
Source File: TracingActivityTrackingPolicyFactory.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isInstance(RoutePolicy routePolicy) {
    return TracingActivityTrackingPolicy.class.isInstance(routePolicy);
}
 
Example #11
Source File: SingleMessageRoutePolicyFactory.java    From funktion-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, RouteDefinition route) {
    return new SingleMessageRoutePolicy();
}
 
Example #12
Source File: ActivityTrackingPolicyFactory.java    From syndesis with Apache License 2.0 2 votes vote down vote up
/**
 * Factory method creating new route policy instance.
 */
RoutePolicy createRoutePolicy(String flowId);
 
Example #13
Source File: ActivityTrackingPolicyFactory.java    From syndesis with Apache License 2.0 2 votes vote down vote up
/**
 * Checks whether this factory produces the given route policy.
 * @param routePolicy the policy to evaluate.
 * @return true if given route policy is produced by this factory.
 */
boolean isInstance(RoutePolicy routePolicy);