![](/img/trans.png)
[英]Convert java POJO to Avro schema object then send to kafka server by KafkaTemplate
[英]Avro schema object generic kafkaTemplate type - produce message
我的 kafka 模板如下所示:
KafkaTemplate<String, InternalSelfServiceData> kafkaTemplate;
其中: InternalSelfServiceData -> Avro 架構對象
當我調用kafkaTemplate.send()
我的返回類型是ListenableFuture<SendResult<String, InternalSelfServiceData>>
。 接下來,我將此數據作為參數傳遞給下一個方法,但我希望此方法是通用方法,因此我希望他們接受這樣的參數ListenableFuture<SendResult<String, ? extends SpecificRecordBase>>
ListenableFuture<SendResult<String, ? extends SpecificRecordBase>>
。
IntelliJ中發生的錯誤是:
所需類型:ListenableFuture <SendResult<String, ? 擴展特定記錄庫>>
提供:ListenableFuture <SendResult<String, InternalSelfServiceData>
任何建議我錯過了什么?
嘗試將您的數據編碼為字節數組(org.apache.avro.specific.SpecificDatumWriter)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.