コード例 #1
0
        private async Task sendBySession(Envelope envelope)
        {
            try
            {
                var message = _protocol.WriteFromEnvelope(envelope);
                message.SessionId = Guid.NewGuid().ToString();


                if (envelope.IsDelayed(DateTime.UtcNow))
                {
                    await _sender.ScheduleMessageAsync(message, envelope.ExecutionTime.Value);
                }
                else
                {
                    await _sender.SendAsync(message);
                }

                await _callback.Successful(envelope);
            }
            catch (Exception e)
            {
                try
                {
                    await _callback.ProcessingFailure(envelope, e);
                }
                catch (Exception exception)
                {
                    _logger.LogException(exception);
                }
            }
        }
コード例 #2
0
        public Task Send(Envelope envelope)
        {
            var message = _protocol.WriteFromEnvelope(envelope);

            message.SessionId = Guid.NewGuid().ToString();


            if (envelope.IsDelayed(DateTime.UtcNow))
            {
                return(_sender.ScheduleMessageAsync(message, envelope.ExecutionTime.Value));
            }

            return(_sender.SendAsync(message));
        }
コード例 #3
0
 public Task <long> ScheduleMessageAsync(Message message, DateTimeOffset scheduleEnqueueTimeUtc)
 {
     return(_client.ScheduleMessageAsync(message, scheduleEnqueueTimeUtc));
 }
コード例 #4
0
 private Task PublishMessageAsync(Message message, ISenderClient client, int?delayInSeconds = null)
 {
     return(delayInSeconds.HasValue
         ? client.ScheduleMessageAsync(message, DateTime.UtcNow.AddSeconds(delayInSeconds.Value))
         : client.SendAsync(message));
 }