public class StreamsBuilderFactoryBean
extends org.springframework.beans.factory.config.AbstractFactoryBean<org.apache.kafka.streams.StreamsBuilder>
implements org.springframework.context.SmartLifecycle, org.springframework.beans.factory.BeanNameAware
AbstractFactoryBean for the StreamsBuilder instance
and lifecycle control for the internal KafkaStreams instance.
A fine grained control on KafkaStreams can be achieved by
KafkaStreamsCustomizers.
| Modifier and Type | Class and Description |
|---|---|
static interface |
StreamsBuilderFactoryBean.Listener
Called whenever a
KafkaStreams is added or removed. |
| Modifier and Type | Field and Description |
|---|---|
static java.time.Duration |
DEFAULT_CLOSE_TIMEOUT
The default
Duration of 10 seconds for close timeout. |
| Constructor and Description |
|---|
StreamsBuilderFactoryBean()
Default constructor that creates the factory without configuration
Properties. |
StreamsBuilderFactoryBean(KafkaStreamsConfiguration streamsConfig)
Construct an instance with the supplied streams configuration.
|
StreamsBuilderFactoryBean(KafkaStreamsConfiguration streamsConfig,
CleanupConfig cleanupConfig)
Construct an instance with the supplied streams configuration and
clean up configuration.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(StreamsBuilderFactoryBean.Listener listener)
Add a
StreamsBuilderFactoryBean.Listener which will be called after starting and stopping the
streams. |
protected org.apache.kafka.streams.StreamsBuilder |
createInstance() |
org.apache.kafka.streams.KafkaStreams |
getKafkaStreams()
Get a managed by this
StreamsBuilderFactoryBean KafkaStreams instance. |
java.util.List<StreamsBuilderFactoryBean.Listener> |
getListeners()
Get the current list of listeners.
|
java.lang.Class<?> |
getObjectType() |
int |
getPhase() |
java.util.Properties |
getStreamsConfiguration() |
org.apache.kafka.streams.Topology |
getTopology()
Providing access to the associated
Topology of this
StreamsBuilderFactoryBean. |
boolean |
isAutoStartup() |
boolean |
isRunning() |
boolean |
removeListener(StreamsBuilderFactoryBean.Listener listener)
Remove a listener.
|
void |
setAutoStartup(boolean autoStartup) |
void |
setBeanName(java.lang.String name) |
void |
setClientSupplier(org.apache.kafka.streams.KafkaClientSupplier clientSupplier) |
void |
setCloseTimeout(int closeTimeout)
Specify the timeout in seconds for the
KafkaStreams.close(Duration)
operation. |
void |
setInfrastructureCustomizer(KafkaStreamsInfrastructureCustomizer infrastructureCustomizer)
Set a customizer to configure the builder and/or topology before creating the stream.
|
void |
setKafkaStreamsCustomizer(KafkaStreamsCustomizer kafkaStreamsCustomizer)
|
void |
setPhase(int phase) |
void |
setStateListener(org.apache.kafka.streams.KafkaStreams.StateListener stateListener) |
void |
setStateRestoreListener(org.apache.kafka.streams.processor.StateRestoreListener stateRestoreListener) |
void |
setStreamsConfiguration(java.util.Properties streamsConfig)
Set the streams configuration
Properties on this factory. |
void |
setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler exceptionHandler) |
void |
start() |
void |
stop() |
void |
stop(java.lang.Runnable callback) |
public static final java.time.Duration DEFAULT_CLOSE_TIMEOUT
Duration of 10 seconds for close timeout.KafkaStreams.close(Duration)public StreamsBuilderFactoryBean()
Properties. It is the factory user's responsibility to properly set
Properties using
setStreamsConfiguration(Properties).public StreamsBuilderFactoryBean(KafkaStreamsConfiguration streamsConfig, CleanupConfig cleanupConfig)
streamsConfig - the streams configuration.cleanupConfig - the cleanup configuration.public StreamsBuilderFactoryBean(KafkaStreamsConfiguration streamsConfig)
streamsConfig - the streams configuration.public void setBeanName(java.lang.String name)
setBeanName in interface org.springframework.beans.factory.BeanNameAwarepublic void setStreamsConfiguration(java.util.Properties streamsConfig)
Properties on this factory.streamsConfig - the streams configuration.@Nullable public java.util.Properties getStreamsConfiguration()
public void setClientSupplier(org.apache.kafka.streams.KafkaClientSupplier clientSupplier)
public void setInfrastructureCustomizer(KafkaStreamsInfrastructureCustomizer infrastructureCustomizer)
infrastructureCustomizer - the customizerpublic void setKafkaStreamsCustomizer(KafkaStreamsCustomizer kafkaStreamsCustomizer)
kafkaStreamsCustomizer - the KafkaStreamsCustomizer to use.public void setStateListener(org.apache.kafka.streams.KafkaStreams.StateListener stateListener)
public void setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler exceptionHandler)
public void setStateRestoreListener(org.apache.kafka.streams.processor.StateRestoreListener stateRestoreListener)
public void setCloseTimeout(int closeTimeout)
KafkaStreams.close(Duration)
operation. Defaults to DEFAULT_CLOSE_TIMEOUT seconds.closeTimeout - the timeout for close in seconds.KafkaStreams.close(Duration)public org.apache.kafka.streams.Topology getTopology()
Topology of this
StreamsBuilderFactoryBean.Topology objectpublic java.lang.Class<?> getObjectType()
getObjectType in interface org.springframework.beans.factory.FactoryBean<org.apache.kafka.streams.StreamsBuilder>getObjectType in class org.springframework.beans.factory.config.AbstractFactoryBean<org.apache.kafka.streams.StreamsBuilder>public void setAutoStartup(boolean autoStartup)
public void setPhase(int phase)
public int getPhase()
getPhase in interface org.springframework.context.PhasedgetPhase in interface org.springframework.context.SmartLifecyclepublic org.apache.kafka.streams.KafkaStreams getKafkaStreams()
StreamsBuilderFactoryBean KafkaStreams instance.StreamsBuilderFactoryBean hasn't been started.public java.util.List<StreamsBuilderFactoryBean.Listener> getListeners()
public void addListener(StreamsBuilderFactoryBean.Listener listener)
StreamsBuilderFactoryBean.Listener which will be called after starting and stopping the
streams.listener - the listener.public boolean removeListener(StreamsBuilderFactoryBean.Listener listener)
listener - the listener.protected org.apache.kafka.streams.StreamsBuilder createInstance()
createInstance in class org.springframework.beans.factory.config.AbstractFactoryBean<org.apache.kafka.streams.StreamsBuilder>public boolean isAutoStartup()
isAutoStartup in interface org.springframework.context.SmartLifecyclepublic void stop(java.lang.Runnable callback)
stop in interface org.springframework.context.SmartLifecyclepublic void start()
start in interface org.springframework.context.Lifecyclepublic void stop()
stop in interface org.springframework.context.Lifecyclepublic boolean isRunning()
isRunning in interface org.springframework.context.Lifecycle