public Form1() { InitializeComponent(); var keyval1 = new KeyValue("key1", "1"); var keyval1_2 = new KeyValue("key1", "2"); var keyval2 = new KeyValue("key2", 7); var keyval2_2 = new KeyValue("key2", 8); var keyValueSchema = new KeyValueSchema("key1", typeof(string).ToString(), new List <KeyValue> { keyval1, keyval1_2 }); var keyValueSchema2 = new KeyValueSchema("key2", typeof(int).ToString(), new List <KeyValue> { keyval1, keyval1_2 }); var row = new Row("p1", "p2", "p3", new List <KeyValue> { keyval1, keyval2 }); var row2 = new Row("p4", "p5", "p6", new List <KeyValue> { keyval1_2, keyval2_2 }); var proj = new ProjectTable("t1", new List <Row> { row, row2 }, new List <KeyValueSchema> { keyValueSchema, keyValueSchema2 }); }
private void PlainKeyValueProducer(string topic) { //var jsonSchem = AvroSchema<JournalEntry>.Of(typeof(JournalEntry)); var jsonSchem = KeyValueSchema <string, string> .Of(ISchema <string> .String, ISchema <string> .String); var builder = new ConsumerConfigBuilder <KeyValue <string, string> >() .Topic(topic) .SubscriptionName($"subscriber-name-{DateTimeHelper.CurrentUnixTimeMillis()}") .AckTimeout(TimeSpan.FromMilliseconds(20000)) .ForceTopicCreation(true) .AcknowledgmentGroupTime(0); var consumer = _client.NewConsumer(jsonSchem, builder); var producerConfig = new ProducerConfigBuilder <KeyValue <string, string> >() .ProducerName(topic.Split("/").Last()) .Topic(topic) .Schema(jsonSchem) .SendTimeout(10000); var producer = _client.NewProducer(jsonSchem, producerConfig); for (var i = 0; i < 10; i++) { var metadata = new Dictionary <string, string> { ["Key"] = "Single", ["Properties"] = JsonSerializer.Serialize(new Dictionary <string, string> { { "Tick", DateTime.Now.Ticks.ToString() } }, new JsonSerializerOptions { WriteIndented = true }) }; var id = producer.NewMessage().Properties(metadata).Value <string, string>(new KeyValue <string, string>("Ebere", $"[{i}]Ebere")).Send(); _output.WriteLine(id.ToString()); } Thread.Sleep(TimeSpan.FromSeconds(5)); for (var i = 0; i < 10; i++) { var msg = consumer.Receive(); if (msg != null) { var kv = msg.Value; _output.WriteLine($"key:{kv.Key}, value:{kv.Value}"); } } }
public ValueSchemaInfoProvider(KeyValueSchema <K, V> OuterInstance) { _outerInstance = OuterInstance; }
public static ISchema <KeyValue <byte[], byte[]> > NewKeyValueBytesSchema() { return(KeyValueSchema <byte[], byte[]> .KvBytes()); }
public static ISchema <KeyValue <K, V> > NewKeyValueSchema <K, V>(Type key, Type value, SchemaType type) { return(KeyValueSchema <K, V> .Of(key, value, type)); }
public static ISchema <KeyValue <K, V> > NewKeyValueSchema <K, V>(ISchema <K> keySchema, ISchema <V> valueSchema, KeyValueEncodingType keyValueEncodingType) { return(KeyValueSchema <K, V> .Of(keySchema, valueSchema, keyValueEncodingType)); }
public static ISchema <KeyValue <K, V> > NewKeyValueSchema <K, V>(ISchema <K> keySchema, ISchema <V> valueSchema) { //return catchExceptions(() => (Schema<KeyValue<K, V>>)getStaticMethod("org.apache.pulsar.client.impl.schema.KeyValueSchema", "of", typeof(Schema), typeof(Schema)).invoke(null, KeySchema, ValueSchema)); return(KeyValueSchema <K, V> .Of(keySchema, valueSchema)); }