2017-07-03 244 views
0

春天引導屬性:我得到的例外下面,當我試圖將消息發送到卡夫卡的話題KafkaProducerException上發送消息到一個主題卡夫卡生產

spring.kafka.bootstrap-servers=localhost:9092 
spring.kafka.client-id=bam 
#spring.kafka.producer.acks= # Number of acknowledgments the producer requires the leader to have received before considering a request complete. 
spring.kafka.producer.batch-size=0 
spring.kafka.producer.bootstrap-servers=localhost:9092 
#spring.kafka.producer.buffer-memory= # Total bytes of memory the producer can use to buffer records waiting to be sent to the server. 
spring.kafka.producer.client-id=bam-producer 
spring.kafka.consumer.auto-offset-reset=earliest 
#spring.kafka.producer.compression-type= # Compression type for all data generated by the producer. 
spring.kafka.producer.key-serializer= org.apache.kafka.common.serialization.StringSerializer 
#spring.kafka.producer.retries= # When greater than zero, enables retrying of failed sends. 
spring.kafka.producer.value-serializer= org.apache.kafka.common.serialization.StringSerializer 
#spring.kafka.properties.*= # Additional properties used to configure the client. 

Caused by: org.springframework.kafka.core.KafkaProducerException: Failed to send; nested exception is org.apache.kafka.common.errors.TimeoutException: Expiring 1 record(s) for bam-0 due to 30004 ms has passed since last append 
at org.springframework.kafka.core.KafkaTemplate$1.onCompletion(KafkaTemplate.java:255) 
at org.apache.kafka.clients.producer.internals.RecordBatch.done(RecordBatch.java:109) 
at org.apache.kafka.clients.producer.internals.RecordBatch.maybeExpire(RecordBatch.java:160) 
at org.apache.kafka.clients.producer.internals.RecordAccumulator.abortExpiredBatches(RecordAccumulator.java:245) 
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:212) 
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:135) 
... 1 more 

由於:org.apache.kafka.common.errors.TimeoutException:由於上次追加已經過去30004毫秒而導致的bam-0的1條記錄失效

我無法弄清楚爲什麼我得到這個例外。有人可以幫忙嗎?

回答

0

問題通過advertised.listeners設置server.properties明文解決:// < ExternalIP>:9092。

注意:Kafka被部署在aws上。

0

生產者試圖發送消息超時。我注意到你在引導中使用localhost。確保經紀人還可以在當地監聽端口9092.

+0

我沒有在本地使用代理。出於安全原因,我在此將其更改爲localhost。僅供參考,我可以通過我的機器telnet經紀人 –

+0

控制檯生產者如何?那樣有用嗎?錯誤表示它將過期一批大小,因此看起來像是向我以某種方式與代理進行通信的問題 – dawsaw

+0

我可以從除代理以外的計算機訪問控制檯生產者嗎? –