K - the key type.V - the outbound data type.R - the reply data type.public class ReplyingKafkaTemplate<K,V,R> extends KafkaTemplate<K,V> implements BatchMessageListener<K,R>, org.springframework.beans.factory.InitializingBean, org.springframework.context.SmartLifecycle, org.springframework.beans.factory.DisposableBean, ReplyingKafkaOperations<K,V,R>
| Modifier and Type | Class and Description |
|---|---|
static class |
ReplyingKafkaTemplate.TemplateRequestReplyFuture<K,V,R>
A listenable future for requests/replies.
|
KafkaOperations.OperationsCallback<K,V,T>, KafkaOperations.ProducerCallback<K,V,T>logger| Constructor and Description |
|---|
ReplyingKafkaTemplate(ProducerFactory<K,V> producerFactory,
GenericMessageListenerContainer<K,R> replyContainer) |
ReplyingKafkaTemplate(ProducerFactory<K,V> producerFactory,
GenericMessageListenerContainer<K,R> replyContainer,
boolean autoFlush) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected CorrelationKey |
createCorrelationId(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
Subclasses can override this to generate custom correlation ids.
|
void |
destroy() |
java.util.Collection<org.apache.kafka.common.TopicPartition> |
getAssignedReplyTopicPartitions()
Return the topics/partitions assigned to the replying listener container.
|
int |
getPhase() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
onMessage(java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<K,R>> data)
Invoked with data from kafka.
|
RequestReplyFuture<K,V,R> |
sendAndReceive(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
Send a request and receive a reply.
|
void |
setAutoStartup(boolean autoStartup) |
void |
setPhase(int phase) |
void |
setReplyTimeout(long replyTimeout) |
void |
setTaskScheduler(org.springframework.scheduling.TaskScheduler scheduler) |
void |
start() |
void |
stop() |
void |
stop(java.lang.Runnable callback) |
closeProducer, doSend, execute, executeInTransaction, flush, getDefaultTopic, getMessageConverter, inTransaction, isTransactional, metrics, partitionsFor, send, send, send, send, send, send, sendDefault, sendDefault, sendDefault, sendDefault, sendOffsetsToTransaction, sendOffsetsToTransaction, setDefaultTopic, setMessageConverter, setProducerListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonMessage, onMessage, onMessagepublic ReplyingKafkaTemplate(ProducerFactory<K,V> producerFactory, GenericMessageListenerContainer<K,R> replyContainer)
public ReplyingKafkaTemplate(ProducerFactory<K,V> producerFactory, GenericMessageListenerContainer<K,R> replyContainer, boolean autoFlush)
public void setTaskScheduler(org.springframework.scheduling.TaskScheduler scheduler)
public void setReplyTimeout(long replyTimeout)
public boolean isRunning()
isRunning in interface org.springframework.context.Lifecyclepublic int getPhase()
getPhase in interface org.springframework.context.Phasedpublic void setPhase(int phase)
public boolean isAutoStartup()
isAutoStartup in interface org.springframework.context.SmartLifecyclepublic void setAutoStartup(boolean autoStartup)
public java.util.Collection<org.apache.kafka.common.TopicPartition> getAssignedReplyTopicPartitions()
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionpublic void start()
start in interface org.springframework.context.Lifecyclepublic void stop()
stop in interface org.springframework.context.Lifecyclepublic void stop(java.lang.Runnable callback)
stop in interface org.springframework.context.SmartLifecyclepublic RequestReplyFuture<K,V,R> sendAndReceive(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
ReplyingKafkaOperationssendAndReceive in interface ReplyingKafkaOperations<K,V,R>record - the record to send.public void destroy()
throws java.lang.Exception
destroy in interface org.springframework.beans.factory.DisposableBeanjava.lang.Exceptionprotected CorrelationKey createCorrelationId(org.apache.kafka.clients.producer.ProducerRecord<K,V> record)
record - the record.public void onMessage(java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<K,R>> data)
GenericMessageListeneronMessage in interface GenericMessageListener<java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<K,R>>>data - the data to be processed.