Package org.apache.camel.component.kafka
Class KafkaComponent
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultComponent
org.apache.camel.support.HealthCheckComponent
org.apache.camel.component.kafka.KafkaComponent
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.CamelContextAware,org.apache.camel.Component,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.HasCamelContext,org.apache.camel.SSLContextParametersAware,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
@Component("kafka")
public class KafkaComponent
extends org.apache.camel.support.HealthCheckComponent
implements org.apache.camel.SSLContextParametersAware
-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected KafkaEndpointprotected voiddoInit()protected voiddoStart()longintlongintbooleanbooleanvoidsetConfiguration(KafkaConfiguration configuration) Allows to pre-configure the Kafka component with common options that the endpoints will reuse.voidsetCreateConsumerBackoffInterval(long createConsumerBackoffInterval) The delay in millis seconds to wait before trying again to create the kafka consumer (kafka-client).voidsetCreateConsumerBackoffMaxAttempts(int createConsumerBackoffMaxAttempts) Maximum attempts to create the kafka consumer (kafka-client), before eventually giving up and failing.voidsetKafkaClientFactory(KafkaClientFactory kafkaClientFactory) Factory to use for creatingKafkaConsumerandKafkaProducerinstances.voidsetKafkaManualCommitFactory(KafkaManualCommitFactory kafkaManualCommitFactory) Factory to use for creatingKafkaManualCommitinstances.voidsetPollExceptionStrategy(PollExceptionStrategy pollExceptionStrategy) To use a custom strategy with the consumer to control how to handle exceptions thrown from the Kafka broker while pooling messages.voidsetSubscribeConsumerBackoffInterval(long subscribeConsumerBackoffInterval) The delay in millis seconds to wait before trying again to subscribe to the kafka broker.voidsetSubscribeConsumerBackoffMaxAttempts(int subscribeConsumerBackoffMaxAttempts) Maximum number the kafka consumer will attempt to subscribe to the kafka broker, before eventually giving up and failing.voidsetSubscribeConsumerTopicMustExists(boolean subscribeConsumerTopicMustExists) Whether when a Camel Kafka consumer is subscribing to a Kafka broker then check whether a topic already exist on the broker, and fail if it does not.voidsetUseGlobalSslContextParameters(boolean useGlobalSslContextParameters) Enable usage of global SSL context parameters.Methods inherited from class org.apache.camel.support.HealthCheckComponent
isHealthCheckConsumerEnabled, isHealthCheckProducerEnabled, setHealthCheckConsumerEnabled, setHealthCheckProducerEnabledMethods inherited from class org.apache.camel.support.DefaultComponent
afterConfiguration, createEndpoint, createEndpoint, doBuild, getAndRemoveOrResolveReferenceParameter, getAndRemoveOrResolveReferenceParameter, getAndRemoveParameter, getAndRemoveParameter, getCamelContext, getComponentPropertyConfigurer, getDefaultName, getEndpointPropertyConfigurer, getExtension, getSupportedExtensions, ifStartsWithReturnRemainder, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, registerExtension, registerExtension, resolveAndRemoveReferenceListParameter, resolveAndRemoveReferenceListParameter, resolveAndRemoveReferenceParameter, resolveAndRemoveReferenceParameter, resolveRawParameterValues, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setLazyStartProducer, setProperties, setProperties, setProperties, useIntrospectionOnEndpoint, useRawUri, validateParameters, validateURIMethods inherited from class org.apache.camel.support.service.BaseService
build, doFail, doLifecycleChange, doResume, doShutdown, doStop, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.CamelContextAware
setCamelContextMethods inherited from interface org.apache.camel.spi.HasCamelContext
getCamelContextMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.SSLContextParametersAware
retrieveGlobalSslContextParametersMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
KafkaComponent
public KafkaComponent() -
KafkaComponent
public KafkaComponent(org.apache.camel.CamelContext context)
-
-
Method Details
-
createEndpoint
protected KafkaEndpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception- Specified by:
createEndpointin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-
getConfiguration
-
setConfiguration
Allows to pre-configure the Kafka component with common options that the endpoints will reuse. -
isUseGlobalSslContextParameters
public boolean isUseGlobalSslContextParameters()- Specified by:
isUseGlobalSslContextParametersin interfaceorg.apache.camel.SSLContextParametersAware
-
setUseGlobalSslContextParameters
public void setUseGlobalSslContextParameters(boolean useGlobalSslContextParameters) Enable usage of global SSL context parameters.- Specified by:
setUseGlobalSslContextParametersin interfaceorg.apache.camel.SSLContextParametersAware
-
getKafkaManualCommitFactory
-
setKafkaManualCommitFactory
Factory to use for creatingKafkaManualCommitinstances. This allows to plugin a custom factory to create customKafkaManualCommitinstances in case special logic is needed when doing manual commits that deviates from the default implementation that comes out of the box. -
getKafkaClientFactory
-
setKafkaClientFactory
Factory to use for creatingKafkaConsumerandKafkaProducerinstances. This allows configuring a custom factory to create instances with logic that extends the vanilla Kafka clients. -
getPollExceptionStrategy
-
setPollExceptionStrategy
To use a custom strategy with the consumer to control how to handle exceptions thrown from the Kafka broker while pooling messages. -
getCreateConsumerBackoffMaxAttempts
public int getCreateConsumerBackoffMaxAttempts() -
setCreateConsumerBackoffMaxAttempts
public void setCreateConsumerBackoffMaxAttempts(int createConsumerBackoffMaxAttempts) Maximum attempts to create the kafka consumer (kafka-client), before eventually giving up and failing. Error during creating the consumer may be fatal due to invalid configuration and as such recovery is not possible. However, one part of the validation is DNS resolution of the bootstrap broker hostnames. This may be a temporary networking problem, and could potentially be recoverable. While other errors are fatal, such as some invalid kafka configurations. Unfortunately, kafka-client does not separate this kind of errors. Camel will by default retry forever, and therefore never give up. If you want to give up after many attempts then set this option and Camel will then when giving up terminate the consumer. To try again, you can manually restart the consumer by stopping, and starting the route. -
getCreateConsumerBackoffInterval
public long getCreateConsumerBackoffInterval() -
setCreateConsumerBackoffInterval
public void setCreateConsumerBackoffInterval(long createConsumerBackoffInterval) The delay in millis seconds to wait before trying again to create the kafka consumer (kafka-client). -
getSubscribeConsumerBackoffMaxAttempts
public int getSubscribeConsumerBackoffMaxAttempts() -
setSubscribeConsumerBackoffMaxAttempts
public void setSubscribeConsumerBackoffMaxAttempts(int subscribeConsumerBackoffMaxAttempts) Maximum number the kafka consumer will attempt to subscribe to the kafka broker, before eventually giving up and failing. Error during subscribing the consumer to the kafka topic could be temporary errors due to network issues, and could potentially be recoverable. Camel will by default retry forever, and therefore never give up. If you want to give up after many attempts, then set this option and Camel will then when giving up terminate the consumer. You can manually restart the consumer by stopping and starting the route, to try again. -
getSubscribeConsumerBackoffInterval
public long getSubscribeConsumerBackoffInterval() -
setSubscribeConsumerBackoffInterval
public void setSubscribeConsumerBackoffInterval(long subscribeConsumerBackoffInterval) The delay in millis seconds to wait before trying again to subscribe to the kafka broker. -
isSubscribeConsumerTopicMustExists
public boolean isSubscribeConsumerTopicMustExists() -
setSubscribeConsumerTopicMustExists
public void setSubscribeConsumerTopicMustExists(boolean subscribeConsumerTopicMustExists) Whether when a Camel Kafka consumer is subscribing to a Kafka broker then check whether a topic already exist on the broker, and fail if it does not. Otherwise, the Camel Kafka consumer will keep attempt to consume from the topic, until it's created on the Kafka broker; and until then the Camel Kafka consumer will fail and log a WARN about UNKNOWN_TOPIC_OR_PARTITION. The option subscribeConsumerBackoffMaxAttempts can be configured to give up trying to subscribe after a given number of attempts. -
doInit
- Overrides:
doInitin classorg.apache.camel.support.DefaultComponent- Throws:
Exception
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-