コード例 #1
0
ファイル: Program.cs プロジェクト: faridprogrammer/nebula
        private static async Task CreateJob()
        {
            try
            {
                var jobId = await _jobManager.CreateNewJobOrUpdateDefinition <SampleJobStep>(
                    string.Empty, "sample-job", nameof(SampleJobStep), new JobConfigurationData
                {
                    MaxBatchSize = 1,
                    MaxConcurrentBatchesPerWorker = 5,
                    IsIndefinite = false,
                    MaxBlockedSecondsPerCycle = 300,
                    QueueTypeName             = QueueType.Delayed
                });

                var queue = Nebula.JobStepSourceBuilder.BuildDelayedJobQueue <SampleJobStep>(jobId);

                var processTime = DateTime.UtcNow;
                await queue.Enqueue(new SampleJobStep { Number = 1 }, processTime.AddSeconds(-5));

                await queue.Enqueue(new SampleJobStep { Number = 2 }, processTime.AddSeconds(1));

                //await queue.Enqueue(new SampleJobStep {Number = 3}, processTime);
                //await queue.Enqueue(new SampleJobStep {Number = 4}, processTime);

                await _jobManager.StartJobIfNotStarted(string.Empty, nameof(SampleJobStep));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Mousavi310/nebula
        private static async Task CreateJob(IJobManager jobManager)
        {
            try
            {
                var jobId = await jobManager.CreateNewJobOrUpdateDefinition <SampleJobStep>(
                    string.Empty, "sample-job", nameof(SampleJobStep), new JobConfigurationData
                {
                    MaxBatchSize = 100,
                    MaxConcurrentBatchesPerWorker = 5,
                    IsIndefinite = true,
                    MaxBlockedSecondsPerCycle = 300,
                    QueueTypeName             = QueueType.Redis
                });

                var initialStep = new SampleJobStep
                {
                    Number = 1
                };

                await Nebula.GetJobQueue <SampleJobStep>(QueueType.Redis).Enqueue(initialStep, jobId);

                await jobManager.StartJobIfNotStarted(string.Empty, nameof(SampleJobStep));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }