Пример #1
0
            /// <summary>
            /// Send the message to Kafka producer
            /// </summary>
            public async Task SetValueAsync(object value, CancellationToken cancellationToken)
            {
                if (value == null)
                {
                    return;
                }

                await entity.SendAndCreateEntityIfNotExistsAsync(value, functionInstanceId, cancellationToken);
            }
        public Task SetValueAsync(object value, CancellationToken cancellationToken)
        {
            if (value == null)
            {
                return(Task.FromResult(0));
            }

            Debug.Assert(value is T);
            var messages = converter.Convert((T)value);

            Debug.Assert(messages != null);

            return(entity.SendAndCreateEntityIfNotExistsAsync(messages, functionInstanceId, cancellationToken));
        }
Пример #3
0
        public Task AddAsync(T item, CancellationToken cancellationToken)
        {
            if (item == null)
            {
                throw new InvalidOperationException("Cannot produce a null message instance.");
            }

            object messageToSend = item;

            if (item.GetType() == typeof(string) || item.GetType() == typeof(byte[]))
            {
                messageToSend = new KafkaEventData <T>(item);
            }

            return(entity.SendAndCreateEntityIfNotExistsAsync(messageToSend, functionInstanceId, cancellationToken));
        }