Exemple #1
0
        public async Task StartScheduledMaterializedViewProcessing(string orgData)
        {
            // Take the Org and Site ID from this and write into a queue.
            try
            {
                //await WriteToScheduledQueue(orgData);
                var scheduledQueue = _queueFactory.CreateQueue <string>(TriggerType.Scheduled);

                using (var tx = StateManager.CreateTransaction())
                {
                    await scheduledQueue.Enqueue(tx, orgData);

                    await tx.CommitAsync();
                }
            }
            catch (Exception e)
            {
                //TODO: Send excpetion up to calling API. decide on error codes.
                Console.WriteLine(e);
                throw;
            }
        }
Exemple #2
0
        /// <summary>
        /// This is the main entry point for your service replica.
        /// This method executes when this replica of your service becomes primary and has write status.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service replica.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            _queueFactory = _queueHandler.CreateFactory(StateManager);


            while (true)
            {
                cancellationToken.ThrowIfCancellationRequested();

                using (var tx = StateManager.CreateTransaction())
                {
                    var scheduledQueue = _queueFactory.CreateQueue <string>(TriggerType.Scheduled);
                    var result         = await scheduledQueue.Dequeue(tx, cancellationToken);

                    if (result.HasValue)
                    {
                        Console.WriteLine(result.Value);
                    }

                    await tx.CommitAsync();
                }
            }
        }