コード例 #1
0
        public async Task <ActionResult> Start()
        {
            try
            {
                await _semaphore.WaitAsync();

                if (_sheduler.ScheduledRecurringMessage == null)
                {
                    SheduleConfig configs = _sheduleConfig.Value;


                    ISendEndpoint _sendEndpoint = await _sendEndpointProvider.GetSendEndpoint(new Uri($"rabbitmq://{configs.Host}/{configs.QuartzQueue}"));

                    _sheduler.ScheduledRecurringMessage =
                        await _sendEndpoint.ScheduleRecurringSend <IRepeatingCommand>(
                            new Uri($"rabbitmq://{configs.Host}/{configs.DestinationQueue}"),
                            new PollExternalSystemSchedule(),
                            new
                    {
                        Message = $"1 sec Quartz {User.Identity.Name}"
                    });

                    _sheduler.ScheduledRecurringMessage2 =
                        await _sendEndpoint.ScheduleRecurringSend <IRepeatingCommand2>(
                            new Uri($"rabbitmq://{configs.Host}/{configs.DestinationQueue}"),
                            new PollExternalSystemSchedule2(),
                            new
                    {
                        Message = $"2 sec Quartz {User.Identity.Name}"
                    });
                }
            }
            finally
            {
                _semaphore.Release();
            }

            return(RedirectToAction(nameof(Get)));
        }