W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
與模式注冊(cè)表服務(wù)器進(jìn)行交互的客戶端抽象是SchemaRegistryClient
接口,該接口具有以下結(jié)構(gòu):
public interface SchemaRegistryClient { SchemaRegistrationResponse register(String subject, String format, String schema); String fetch(SchemaReference schemaReference); String fetch(Integer id); }
Spring Cloud Stream提供了開箱即用的實(shí)現(xiàn),可以與其自己的模式服務(wù)器進(jìn)行交互,也可以與Confluent Schema注冊(cè)中心進(jìn)行交互。
可以使用@EnableSchemaRegistryClient
來(lái)配置Spring Cloud Stream模式注冊(cè)表的客戶端,如下所示:
@EnableBinding(Sink.class) @SpringBootApplication @EnableSchemaRegistryClient public static class AvroSinkApplication { ... }
默認(rèn)轉(zhuǎn)換器經(jīng)過(guò)優(yōu)化,不僅可以緩存來(lái)自遠(yuǎn)程服務(wù)器的模式,還可以緩存parse()
和toString()
方法,這是非常昂貴的。因此,它使用了不緩存響應(yīng)的DefaultSchemaRegistryClient
。如果要更改默認(rèn)行為,則可以直接在代碼上使用客戶端,并將其覆蓋為所需的結(jié)果。為此,您必須將屬性spring.cloud.stream.schemaRegistryClient.cached=true
添加到應(yīng)用程序?qū)傩灾小?/blockquote>
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: