public class KafkaAdmin
extends java.lang.Object
implements org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.SmartInitializingSingleton
AdminClient
to create topics defined
in the application context.Constructor and Description |
---|
KafkaAdmin(java.util.Map<java.lang.String,java.lang.Object> config)
Create an instance with an
AdminClient based on the supplied
configuration. |
Modifier and Type | Method and Description |
---|---|
void |
afterSingletonsInstantiated() |
java.util.Map<java.lang.String,java.lang.Object> |
getConfig()
Get an unmodifiable copy of this admin's configuration.
|
boolean |
initialize()
Call this method to check/add topics; this might be needed if the broker was not
available when the application context was initialized, and
fatalIfBrokerNotAvailable is false,
or autoCreate was set to false. |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setAutoCreate(boolean autoCreate)
Set to false to suppress auto creation of topics during context initialization.
|
void |
setCloseTimeout(int closeTimeout)
Set the close timeout in seconds.
|
void |
setFatalIfBrokerNotAvailable(boolean fatalIfBrokerNotAvailable)
Set to true if you want the application context to fail to load if we are unable
to connect to the broker during initialization, to check/add topics.
|
void |
setOperationTimeout(int operationTimeout)
Set the operation timeout in seconds.
|
public KafkaAdmin(java.util.Map<java.lang.String,java.lang.Object> config)
AdminClient
based on the supplied
configuration.config
- the configuration for the AdminClient
.public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
public void setCloseTimeout(int closeTimeout)
closeTimeout
- the timeout.public void setOperationTimeout(int operationTimeout)
operationTimeout
- the timeout.public void setFatalIfBrokerNotAvailable(boolean fatalIfBrokerNotAvailable)
fatalIfBrokerNotAvailable
- true to fail.public void setAutoCreate(boolean autoCreate)
autoCreate
- boolean flag to indicate creating topics or not during context initializationinitialize()
public java.util.Map<java.lang.String,java.lang.Object> getConfig()
public void afterSingletonsInstantiated()
afterSingletonsInstantiated
in interface org.springframework.beans.factory.SmartInitializingSingleton
public final boolean initialize()
fatalIfBrokerNotAvailable
is false,
or autoCreate
was set to false.setFatalIfBrokerNotAvailable(boolean)
,
setAutoCreate(boolean)