public async Task ProcessEventsAsync(PartitionContext context, IEnumerable <EventData> messages)
        {
            //forward to message processor
            List <QueueMessage> qms = messages.Select(ed => Converter.ToQueueMessage(ed, context.PartitionId)).ToList();

            await _messageProcessor.ProcessMessagesAsync(qms).ConfigureAwait(false);

            //checkpoint
            DateTimeOffset now = DateTimeOffset.Now;

            if (now - _lastCheckpointTime >= CheckpointInterval)
            {
                await context.CheckpointAsync().ConfigureAwait(false);

                _lastCheckpointTime = now;
            }
        }
Пример #2
0
        private async Task ProcessMessagesAsync(Message message, CancellationToken token)
        {
            T payload = null;

            if (message.Body[0] == charAt)
            {
                payload = OneSolution.ServiceBus.XmlMessageExtention.ParseXmlMessage <T>(message);
            }
            else
            {
                payload = JsonSerializer.Deserialize <T>(Encoding.UTF8.GetString(message.Body));
            }
            var lockToken = message.SystemProperties.LockToken;
            await processor.ProcessMessagesAsync(payload, lockToken, token).ConfigureAwait(false);

            await receiver.CompleteAsync(lockToken).ConfigureAwait(false);
        }