public class ContainerProperties
extends java.lang.Object
Constructor and Description |
---|
ContainerProperties(java.util.regex.Pattern topicPattern) |
ContainerProperties(java.lang.String... topics) |
ContainerProperties(TopicPartitionInitialOffset... topicPartitions) |
Modifier and Type | Method and Description |
---|---|
int |
getAckCount() |
AbstractMessageListenerContainer.AckMode |
getAckMode() |
long |
getAckTime() |
org.apache.kafka.clients.consumer.OffsetCommitCallback |
getCommitCallback() |
org.apache.kafka.clients.consumer.ConsumerRebalanceListener |
getConsumerRebalanceListener() |
org.springframework.core.task.AsyncListenableTaskExecutor |
getConsumerTaskExecutor() |
GenericErrorHandler<?> |
getGenericErrorHandler() |
java.lang.Long |
getIdleEventInterval() |
org.springframework.core.task.AsyncListenableTaskExecutor |
getListenerTaskExecutor() |
java.lang.Object |
getMessageListener() |
long |
getPauseAfter() |
long |
getPollTimeout() |
int |
getQueueDepth() |
long |
getShutdownTimeout() |
TopicPartitionInitialOffset[] |
getTopicPartitions() |
java.util.regex.Pattern |
getTopicPattern() |
java.lang.String[] |
getTopics() |
boolean |
isAckOnError() |
boolean |
isPauseEnabled() |
boolean |
isSyncCommits() |
void |
setAckCount(int count)
Set the number of outstanding record count after which offsets should be
committed when
AbstractMessageListenerContainer.AckMode.COUNT or AbstractMessageListenerContainer.AckMode.COUNT_TIME is being used. |
void |
setAckMode(AbstractMessageListenerContainer.AckMode ackMode)
Set the ack mode to use when auto ack (in the configuration properties) is false.
|
void |
setAckOnError(boolean ackOnError)
Set whether or not the container should commit offsets (ack messages) where the
listener throws exceptions.
|
void |
setAckTime(long ackTime)
Set the time (ms) after which outstanding offsets should be committed when
AbstractMessageListenerContainer.AckMode.TIME or AbstractMessageListenerContainer.AckMode.COUNT_TIME is being used. |
void |
setCommitCallback(org.apache.kafka.clients.consumer.OffsetCommitCallback commitCallback)
Set the commit callback; by default a simple logging callback is used to log
success at DEBUG level and failures at ERROR level.
|
void |
setConsumerRebalanceListener(org.apache.kafka.clients.consumer.ConsumerRebalanceListener consumerRebalanceListener)
Set the user defined
ConsumerRebalanceListener implementation. |
void |
setConsumerTaskExecutor(org.springframework.core.task.AsyncListenableTaskExecutor consumerTaskExecutor)
Set the executor for threads that poll the consumer.
|
void |
setErrorHandler(ErrorHandler errorHandler)
Set the error handler to call when the listener throws an exception.
|
void |
setGenericErrorHandler(GenericErrorHandler<?> errorHandler)
Set the error handler to call when the listener throws an exception.
|
void |
setIdleEventInterval(java.lang.Long idleEventInterval)
Set the idle event interval; when set, an event is emitted if a poll returns
no records and this interval has elapsed since a record was returned.
|
void |
setListenerTaskExecutor(org.springframework.core.task.AsyncListenableTaskExecutor listenerTaskExecutor)
Set the executor for threads that invoke the listener.
|
void |
setMessageListener(java.lang.Object messageListener)
Set the message listener; must be a
MessageListener
or AcknowledgingMessageListener . |
void |
setPauseAfter(long pauseAfter)
When using Kafka group management and
setPauseEnabled(boolean) is
true, set the delay after which the consumer should be paused. |
void |
setPauseEnabled(boolean pauseEnabled)
Set to true to avoid rebalancing when this consumer is slow or throws a
qualifying exception - pause the consumer.
|
void |
setPollTimeout(long pollTimeout)
Set the max time to block in the consumer waiting for records.
|
void |
setQueueDepth(int queueDepth)
Set the queue depth for handoffs from the consumer thread to the listener
thread.
|
void |
setShutdownTimeout(long shutdownTimeout)
Set the timeout for shutting down the container.
|
void |
setSyncCommits(boolean syncCommits)
Set whether or not to call consumer.commitSync() or commitAsync() when the
container is responsible for commits.
|
public ContainerProperties(java.lang.String... topics)
public ContainerProperties(java.util.regex.Pattern topicPattern)
public ContainerProperties(TopicPartitionInitialOffset... topicPartitions)
public void setMessageListener(java.lang.Object messageListener)
MessageListener
or AcknowledgingMessageListener
.messageListener
- the listener.public void setAckMode(AbstractMessageListenerContainer.AckMode ackMode)
#setPollTimeout(long) pollTimeout
.AcknowledgingMessageListener
.
ackMode
- the AbstractMessageListenerContainer.AckMode
; default BATCH.public void setPollTimeout(long pollTimeout)
pollTimeout
- the timeout in ms; default 1000.public void setAckCount(int count)
AbstractMessageListenerContainer.AckMode.COUNT
or AbstractMessageListenerContainer.AckMode.COUNT_TIME
is being used.count
- the countpublic void setAckTime(long ackTime)
AbstractMessageListenerContainer.AckMode.TIME
or AbstractMessageListenerContainer.AckMode.COUNT_TIME
is being used. Should be
larger thanackTime
- the timepublic void setErrorHandler(ErrorHandler errorHandler)
errorHandler
- the error handler.setGenericErrorHandler(GenericErrorHandler)
public void setGenericErrorHandler(GenericErrorHandler<?> errorHandler)
errorHandler
- the error handler.public void setConsumerTaskExecutor(org.springframework.core.task.AsyncListenableTaskExecutor consumerTaskExecutor)
consumerTaskExecutor
- the executorpublic void setListenerTaskExecutor(org.springframework.core.task.AsyncListenableTaskExecutor listenerTaskExecutor)
listenerTaskExecutor
- the executor.public void setPauseAfter(long pauseAfter)
setPauseEnabled(boolean)
is
true, set the delay after which the consumer should be paused. Default 10000.pauseAfter
- the delay.public void setPauseEnabled(boolean pauseEnabled)
pauseEnabled
- true to pause.setPauseAfter(long)
public void setQueueDepth(int queueDepth)
queueDepth
- the queue depth.public void setShutdownTimeout(long shutdownTimeout)
#stop(Runnable)
will block for, before
returning.shutdownTimeout
- the shutdown timeout.public void setConsumerRebalanceListener(org.apache.kafka.clients.consumer.ConsumerRebalanceListener consumerRebalanceListener)
ConsumerRebalanceListener
implementation.consumerRebalanceListener
- the ConsumerRebalanceListener
instancepublic void setCommitCallback(org.apache.kafka.clients.consumer.OffsetCommitCallback commitCallback)
commitCallback
- the callback.public void setSyncCommits(boolean syncCommits)
syncCommits
- true to use commitSync().public void setIdleEventInterval(java.lang.Long idleEventInterval)
idleEventInterval
- the interval.public void setAckOnError(boolean ackOnError)
ackMode
and is
effective only when the kafka property enable.auto.commit
is false
;
it is not applicable to manual ack modes. When this property is set to true
(the default), all messages handled will have their offset committed. When set to
false
, offsets will be committed only for successfully handled messages.
Manual acks will always be applied. Bear in mind that, if the next message is
successfully handled, its offset will be committed, effectively committing the
offset of the failed message anyway, so this option has limited applicability.
Perhaps useful for a component that starts throwing exceptions consistently;
allowing it to resume when restarted from the last successfully processed message.ackOnError
- whether the container should acknowledge messages that throw
exceptions.public java.lang.String[] getTopics()
public java.util.regex.Pattern getTopicPattern()
public TopicPartitionInitialOffset[] getTopicPartitions()
public AbstractMessageListenerContainer.AckMode getAckMode()
public int getAckCount()
public long getAckTime()
public java.lang.Object getMessageListener()
public long getPollTimeout()
public org.springframework.core.task.AsyncListenableTaskExecutor getConsumerTaskExecutor()
public org.springframework.core.task.AsyncListenableTaskExecutor getListenerTaskExecutor()
public GenericErrorHandler<?> getGenericErrorHandler()
public long getPauseAfter()
public boolean isPauseEnabled()
public int getQueueDepth()
public long getShutdownTimeout()
public org.apache.kafka.clients.consumer.ConsumerRebalanceListener getConsumerRebalanceListener()
public org.apache.kafka.clients.consumer.OffsetCommitCallback getCommitCallback()
public boolean isSyncCommits()
public java.lang.Long getIdleEventInterval()
public boolean isAckOnError()