這篇文章給大家介紹Pulsar IO 中怎么調(diào)用Schema ,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
我們提供的服務(wù)有:做網(wǎng)站、網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、長陽ssl等。為成百上千企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的長陽網(wǎng)站制作公司
Schema 是一種描述數(shù)據(jù)的數(shù)據(jù) 。例如,數(shù)據(jù)庫中表的信息和字段類型等都是 Schema。Pulsar 對 Schema 也有比較好的支持。
public class SensorReading {
public float temperature;
public SensorReading(float temperature) {
this.temperature = temperature;
}
// A no-arg constructor is required
public SensorReading() {
}
public float getTemperature() {
return temperature;
}
public void setTemperature(float temperature) {
this.temperature = temperature;
}
}
Producer<SensorReading> producer = client.newProducer(JSONSchema.of(SensorReading.class))
.topic("my-topic")
.create();
Consumer consumer = client.newConsumer(JSONSchema.of(SensorReading.class))
.topic("my-topic")
.subscriptionName("my-subscription")
.subscribe();
if (conf.getSerdeClassName() != null && !conf.getSerdeClassName().isEmpty()) { schema = (Schema<T>) topicSchema.getSchema(topic, typeArg, conf.getSerdeClassName(), true); } else { schema = (Schema<T>) topicSchema.getSchema(topic, typeArg, conf.getSchemaType(), true); }
case NONE:
return (Schema<T>) Schema.BYTES;
case AUTO_CONSUME:
case AUTO:
return (Schema<T>) Schema.AUTO_CONSUME();
case STRING:
return (Schema<T>) Schema.STRING;
case AVRO:
return AvroSchema.of(SchemaDefinition.<T>builder().withPojo(clazz).build());
case JSON:
return JSONSchema.of(SchemaDefinition.<T>builder().withPojo(clazz).build());
case KEY_VALUE:
return (Schema<T>)Schema.KV_BYTES();
case PROTOBUF:
return ProtobufSchema.ofGenericClass(clazz, Collections.emptyMap());
}
關(guān)于Pulsar IO 中怎么調(diào)用Schema 就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
分享題目:PulsarIO中怎么調(diào)用Schema
文章地址:http://aaarwkj.com/article14/pcopde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、電子商務(wù)、移動(dòng)網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)