Exemple #1
0
        private async Task ProcessCommand(ICommand command, JobDataMap jobDataMap, IMessageMetadata metadata, JobKey jobKey)
        {
            var options = Get <ExecutionOptions>(jobDataMap, ExecutionOptionsKey);

            if (options.SuccesEventType == null)
            {
                throw new OptionsNotFilledException("options do not have SuccessEventType for key " + jobKey);
            }

            var commandMetadata = metadata.CreateChild(command.Id,
                                                       new ProcessEntry(nameof(QuartzJob), PassingCommandToExecutor, CommandRaiseTime));

            //waiting domain event by correlation id
            await _executor.Prepare(command, commandMetadata)
            .Expect(options.SuccesEventType)
            .Execute(options.Timeout, true);

            _quartzLogger.Information("job {key} succeed", jobKey.Name);

            var successMetadata = commandMetadata.CreateChild(Guid.NewGuid().ToString(),
                                                              new ProcessEntry(nameof(QuartzJob),
                                                                               "Publishing success notification",
                                                                               "Job execution completed succesfully. Command executed and confirmed."));

            var jobSucceeded = new JobSucceeded(jobKey.Name, jobKey.Group, command);

            _publisher.Publish(jobSucceeded, successMetadata);
        }
 public ICommandWaiter Prepare <T>(T cmd, IMessageMetadata metadata = null) where T : ICommand
 {
     if (!IsConnected)
     {
         throw new NotConnectedException();
     }
     return(_commandExecutor.Prepare(cmd, metadata));
 }
 public ICommandWaiter Prepare <T>(T cmd, IMessageMetadata metadata = null) where T : ICommand
 {
     return(_commandExecutor.Prepare(cmd, metadata));
 }
Exemple #4
0
 public override void Prepare()
 {
     executor.Prepare(this);
 }