예제 #1
0
        public override void Process(K key, V value)
        {
            LogProcessingKeyValue(key, value);

            long timestamp = Context.Timestamp;

            if (timestamp < 0)
            {
                throw new StreamsException($"Invalid (negative) timestamp of {timestamp } for output record <{key}:{value}>.");
            }

            if (KeySerDes == null || ValueSerDes == null)
            {
                var s            = KeySerDes == null ? "key" : "value";
                var errorMessage =
                    $"{logPrefix}The {s} serdes ({(KeySerDes == null ? Key.GetType() : Value.GetType())}) is not compatible to the actual {s} ({(KeySerDes == null ? typeof(K) : typeof(V))}) for this processor. Change the default {s} serdes in StreamConfig or provide correct Serdes via method parameters(using the DSL)";
                log.LogError(errorMessage);
                throw new StreamsException(errorMessage);
            }

            var topicName = topicNameExtractor.Extract(key, value, Context.RecordContext);

            if (partitioner != null)
            {
                int partition = partitioner.Invoke(topicName, key, value);
                Context.RecordCollector.Send(topicName, key, value, Context.RecordContext.Headers, partition, timestamp, KeySerDes,
                                             ValueSerDes);
            }
            else
            {
                Context.RecordCollector.Send(topicName, key, value, Context.RecordContext.Headers, timestamp, KeySerDes,
                                             ValueSerDes);
            }
        }
        public override void Process(K key, V value)
        {
            LogProcessingKeyValue(key, value);

            long timestamp = Context.Timestamp;

            if (timestamp < 0)
            {
                throw new StreamsException($"Invalid (negative) timestamp of {timestamp } for output record <{key}:{value}>.");
            }

            if (KeySerDes == null || ValueSerDes == null)
            {
                log.Error($"{logPrefix}Impossible to send sink data because keySerdes and/or valueSerdes is not setted ! KeySerdes : {(KeySerDes != null ? KeySerDes.GetType().Name : "NULL")} | ValueSerdes : {(ValueSerDes != null ? ValueSerDes.GetType().Name : "NULL")}.");
                var s = KeySerDes == null ? "key" : "value";
                throw new StreamsException($"{logPrefix}The {s} serdes is not compatible to the actual {s} for this processor. Change the default {s} serdes in StreamConfig or provide correct Serdes via method parameters(using the DSL)");
            }

            var topicName = topicNameExtractor.Extract(key, value, Context.RecordContext);

            Context.RecordCollector.Send(topicName, key, value, null, timestamp, KeySerDes, ValueSerDes);
        }
예제 #3
0
        public override void Process(K key, V value)
        {
            LogProcessingKeyValue(key, value);

            long timestamp = Context.Timestamp;

            if (timestamp < 0)
            {
                throw new StreamsException($"Invalid (negative) timestamp of {timestamp } for output record <{key}:{value}>.");
            }

            if (KeySerDes == null || ValueSerDes == null)
            {
                log.Error($"{logPrefix}Impossible to send sink data because keySerdes and/or valueSerdes is not setted ! KeySerdes : {(KeySerDes != null ? KeySerDes.GetType().Name : "NULL")} | ValueSerdes : {(ValueSerDes != null ? ValueSerDes.GetType().Name : "NULL")}.");
                var s = KeySerDes == null ? "key" : "value";
                throw new StreamsException($"{logPrefix}Invalid {s} serdes for this processor. Default {s} serdes is not the same type. Please set a explicit {s} serdes.");
            }

            var topicName = topicNameExtractor.Extract(key, value, Context.RecordContext);

            Context.RecordCollector.Send(topicName, key, value, null, timestamp, KeySerDes, ValueSerDes);
        }