org.apache.camel.component.kafka.KafkaComponent Java Examples

The following examples show how to use org.apache.camel.component.kafka.KafkaComponent. 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: WordRoute.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
public void configure() throws Exception {
    // lets shutdown quicker
    getContext().getShutdownStrategy().setTimeout(10);

    // configure the kafka component to use the broker
    KafkaComponent kafka = new KafkaComponent();

    // you can specify more brokers separated by comma
    kafka.setBrokers("localhost:9092");

    // add component to CamelContext
    getContext().addComponent("kafka", kafka);

    // use a timer to trigger every 100 milli seconds and generate a random word
    // which is sent to kafka
    from("timer:foo?period=100")
        .bean(new WordBean())
        .to("kafka:words")
        .to("log:words?groupInterval=1000");
}
 
Example #2
Source File: KafkaComponentAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Lazy
@Bean(name = "kafka-component")
@ConditionalOnMissingBean(KafkaComponent.class)
public KafkaComponent configureKafkaComponent() throws Exception {
    KafkaComponent component = new KafkaComponent();
    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<KafkaComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId)
                    ? HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.kafka.customizer",
                            ((HasId) customizer).getId())
                    : HierarchicalPropertiesEvaluator.evaluate(
                            applicationContext.getEnvironment(),
                            "camel.component.customizer",
                            "camel.component.kafka.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure component {}, with customizer {}",
                        component, customizer);
                customizer.customize(component);
            }
        }
    }
    return component;
}
 
Example #3
Source File: DebeziumTransactionTransformerApplication.java    From eda-tutorial with Apache License 2.0 5 votes vote down vote up
@Bean
public KafkaComponent kafka() {
    KafkaComponent kafkaComponent = new KafkaComponent();
    KafkaConfiguration configuration = new KafkaConfiguration();
    configuration.setBrokers("my-cluster-kafka-bootstrap.strimzi-infra.svc:9092");
    configuration.setGroupId("debezium-transaction-transformer");
    kafkaComponent.setConfiguration(configuration);
    return kafkaComponent;
}
 
Example #4
Source File: AccountApplication.java    From eda-tutorial with Apache License 2.0 5 votes vote down vote up
@Bean
public KafkaComponent kafka() {
    KafkaComponent kafkaComponent = new KafkaComponent();
    KafkaConfiguration configuration = new KafkaConfiguration();
    configuration.setBrokers("my-cluster-kafka-bootstrap.strimzi-infra.svc:9092");
    configuration.setGroupId("account");
    kafkaComponent.setConfiguration(configuration);
    return kafkaComponent;
}
 
Example #5
Source File: KafkaReceiverApplication.java    From eda-tutorial with Apache License 2.0 5 votes vote down vote up
@Produces
@Named("kafka")
public KafkaComponent kafka() {
    KafkaComponent kafkaComponent = new KafkaComponent();
    KafkaConfiguration configuration = new KafkaConfiguration();
    configuration.setBrokers("localhost:9092");
    kafkaComponent.setConfiguration(configuration);
    return kafkaComponent;
}
 
Example #6
Source File: KafkaSenderApplication.java    From eda-tutorial with Apache License 2.0 5 votes vote down vote up
@Bean
public KafkaComponent kafka() {
    KafkaComponent kafkaComponent = new KafkaComponent();
    KafkaConfiguration configuration = new KafkaConfiguration();
    configuration.setBrokers("my-cluster-kafka-bootstrap.strimzi-infra.svc:9092");
    kafkaComponent.setConfiguration(configuration);
    return kafkaComponent;
}
 
Example #7
Source File: KafkaReceiverApplication.java    From eda-tutorial with Apache License 2.0 5 votes vote down vote up
@Bean
public KafkaComponent kafka() {
    KafkaComponent kafkaComponent = new KafkaComponent();
    KafkaConfiguration configuration = new KafkaConfiguration();
    configuration.setBrokers("my-cluster-kafka-bootstrap.strimzi-infra.svc:9092");
    kafkaComponent.setConfiguration(configuration);
    return kafkaComponent;
}