Пример #1
0
        public void AddToQueue(string queue, string jobId)
        {
            IPersistentJobQueueProvider provider        = _queueProviders.GetProvider(queue);
            IPersistentJobQueue         persistentQueue = provider.GetJobQueue(_connection);

            QueueCommand(_ => persistentQueue.Enqueue(queue, jobId));
        }
Пример #2
0
        public override void Commit()
        {
            if (Logger.IsDebugEnabled())
            {
                foreach (var tuple in _jobsToEnqueue)
                {
                    Logger.Debug($"Enqueuing Job ({tuple.Item2}), on queue: '{tuple.Item1}'\r\n");
                }

                Logger.Debug($"\r\nCommit:\r\n {string.Join("\r\n", _writeModels.Select(SerializeWriteModel))}");
            }

            var writeTasks = _jobsToEnqueue.Select(t =>
            {
                var queue = t.Item1;
                var jobId = t.Item2;
                IPersistentJobQueueProvider provider = _queueProviders.GetProvider(queue);
                IPersistentJobQueue persistentQueue  = provider.GetJobQueue(_connection);
                return(Task.Run(() => persistentQueue.Enqueue(queue, jobId)));
            }).ToList();

            if (_writeModels.Any())
            {
                var writeTask = _connection
                                .Database
                                .GetCollection <BsonDocument>(_connection.JobGraph.CollectionNamespace.CollectionName)
                                .BulkWriteAsync(_writeModels);

                writeTasks.Add(writeTask);
            }


            // make sure to run tasks on default task scheduler
            Task.Run(() => Task.WhenAll(writeTasks)).GetAwaiter().GetResult();
        }
        public override void AddToQueue(string queue, string jobId)
        {
            IPersistentJobQueueProvider provider        = _queueProviders.GetProvider(queue);
            IPersistentJobQueue         persistentQueue = provider.GetJobQueue(_database);

            QueueCommand(_ =>
            {
                persistentQueue.Enqueue(queue, jobId);
            });
        }
        public void AddToQueue(string queue, string jobId)
        {
            IPersistentJobQueueProvider provider        = _queueProviders.GetProvider(queue);
            IPersistentJobQueue         persistentQueue = provider.GetJobQueue(_connection);

            QueueCommand(_ =>
            {
                persistentQueue.Enqueue(queue, jobId);
                return(Task.FromResult(0));
            });
        }
        public void AddToQueue(string queue, string jobId)
        {
            if (string.IsNullOrEmpty(queue))
            {
                throw new ArgumentNullException(nameof(queue));
            }
            if (string.IsNullOrEmpty(jobId))
            {
                throw new ArgumentNullException(nameof(jobId));
            }

            IPersistentJobQueueProvider provider        = connection.QueueProviders.GetProvider(queue);
            IPersistentJobQueue         persistentQueue = provider.GetJobQueue();

            QueueCommand(() => persistentQueue.Enqueue(queue, jobId));
        }