org.apache.camel.component.vertx.VertxComponent Java Examples

The following examples show how to use org.apache.camel.component.vertx.VertxComponent. 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: VertxResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/verify/instance")
@GET
@Produces(MediaType.TEXT_PLAIN)
public boolean quarkusVertxInstanceUsedInVertxComponent() {
    VertxComponent component = camelContext.getComponent("vertx", VertxComponent.class);
    return component.getVertx() == vertx;
}
 
Example #2
Source File: VertxComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "vertx-component")
@ConditionalOnMissingBean(VertxComponent.class)
public VertxComponent configureVertxComponent() throws Exception {
    VertxComponent component = new VertxComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    CamelPropertiesHelper.setCamelProperties(camelContext, component,
            parameters, false);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ComponentCustomizer<VertxComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.vertx.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.vertx.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #3
Source File: LiveScoreRouteBuilder.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
@Override
public void configure() throws Exception {
    // use vertx instance on the Camel vertx component
    getContext().getComponent("vertx", VertxComponent.class).setVertx(vertx);

    // initialize the list of games which is called when a new client connects to Vert.X backend
    from("direct:init-games").routeId("init-games")
        .log("Init games event")
        .to("goal:games.csv")
        // the frontend expect one message per game so split
        .split(body())
            .to("vertx:games");

    // the route for handling live score updates from the goal
    // component which is published to vertx addresses
    from("goal:goals.csv").routeId("livescore").autoStartup(false)
        .log("Goal event: ${header.action} -> ${body}")
        .choice()
            .when(header("action").isEqualTo("clock"))
                .to("vertx:clock")
            .when(header("action").isEqualTo("goal"))
                .to("vertx:goals");

    // consume from vertx control address when the user clicks the control buttons
    // then we want to start/suspend the livescore route accordingly
    from("vertx:control").routeId("control")
        .log("Control event: ${body}")
        .toD("controlbus:route?routeId=livescore&async=true&action=${body}");
}
 
Example #4
Source File: VertxProcessor.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep
CamelRuntimeBeanBuildItem configureVertxRegistryBean(CamelVertxRecorder recorder, VertxBuildItem vertx) {
    return new CamelRuntimeBeanBuildItem("vertx", VertxComponent.class.getName(),
            recorder.createVertxComponent(vertx.getVertx()));
}
 
Example #5
Source File: CamelVertxRecorder.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
public RuntimeValue<VertxComponent> createVertxComponent(RuntimeValue<Vertx> vertx) {
    VertxComponent component = new VertxComponent();
    component.setVertx(vertx.getValue());
    return new RuntimeValue<>(component);
}