Example #1
0
        async Task <bool> IPersist.ToggleMarkAllAsync(string q, PersistedMessageStatusOptions newMark, PersistedMessageStatusOptions oldMark, CancellationToken token)
        {
            if (this.serviceDown)
            {
                throw new ServiceEndpointDownException("Mongo Persist Service is Down");
            }

            IMongoCollection <PersistedMessage> collection = this.GetCollection();



            try {
                token.ThrowIfCancellationRequested();
                FilterDefinitionBuilder <PersistedMessage> fBuilder = Builders <PersistedMessage> .Filter;

                var qfilter = fBuilder.And(fBuilder.Eq(g => g.Status, oldMark), fBuilder.Eq(g => g.Queue, q));
                var update  = Builders <PersistedMessage> .Update.Set(g => g.Status, newMark);

                await collection.UpdateManyAsync(qfilter, update, null, token);

                return(true);
            } catch (Exception e) {
                this.serviceDown = true;
                throw new ServiceEndpointDownException("Mongo Persist Service is Down", e);
            }
        }
Example #2
0
        bool IPersist.ToggleMarkAll(string q, PersistedMessageStatusOptions newMark, PersistedMessageStatusOptions oldMark)
        {
            Task <bool> t = ((IPersist)this).ToggleMarkAllAsync(q, newMark, oldMark);

            t.Wait();
            return(t.Result);
        }
Example #3
0
        PersistedMessage IPersist.Mark(Guid Id, PersistedMessageStatusOptions mark)
        {
            Task <PersistedMessage> t = ((IPersist)this).MarkAsync(Id, mark);

            t.Wait();
            return(t.Result);
        }
Example #4
0
        async Task <PersistedMessage> IPersist.MarkAsync(Guid Id, PersistedMessageStatusOptions mark, CancellationToken token)
        {
            if (this.serviceDown)
            {
                throw new ServiceEndpointDownException("Mongo Persist Service is Down");
            }

            PersistedMessage pop = null;
            IMongoCollection <PersistedMessage> collection = this.GetCollection();

            try {
                token.ThrowIfCancellationRequested();
                var update = Builders <PersistedMessage> .Update.Set(g => g.Status, mark);

                var filter = Builders <PersistedMessage> .Filter.Eq(m => m.Id, Id);


                await collection.UpdateOneAsync(filter, update, null, token);
            } catch (Exception e) {
                this.serviceDown = true;
                throw new ServiceEndpointDownException("Mongo Persist Service is Down", e);
            }

            return(pop);
        }
Example #5
0
        async Task <PersistedMessage> IPersist.PeekAndMarkAsync(string q, PersistedMessageStatusOptions mark, CancellationToken token, Guid messageId)
        {
            if (this.serviceDown)
            {
                throw new ServiceEndpointDownException("Mongo Persist Service is Down");
            }

            IMongoCollection <PersistedMessage> collection = this.GetCollection();
            PersistedMessage pop = null;

            try {
                token.ThrowIfCancellationRequested();
                FilterDefinitionBuilder <PersistedMessage> fBuilder = Builders <PersistedMessage> .Filter;

                //var qfilter = fBuilder.And(fBuilder.Eq(g => g.Status, PersistedMessageStatusOptions.ReadyToProcess), fBuilder.Eq(g => g.Queue, q), fBuilder.Lte(g => g.DateStamp, DateTime.UtcNow));
                var qfilter = fBuilder.Eq(g => g.Id, messageId);
                var update  = Builders <PersistedMessage> .Update.Set(g => g.Status, mark);

                //var sort = Builders<PersistedMessage>.Sort.Ascending(e => e.DateStamp).Ascending(e => e.Ordinal);
                var options = new FindOneAndUpdateOptions <PersistedMessage>()
                {
                    ReturnDocument = ReturnDocument.After
                };

                pop = await collection.FindOneAndUpdateAsync(qfilter, update, options, token);
            } catch (Exception e) {
                this.serviceDown = true;
                throw new ServiceEndpointDownException("Mongo Persist Service is Down", e);
            }

            return(pop);
        }
Example #6
0
        PersistedMessage IPersist.PeekAndMark(string q, PersistedMessageStatusOptions mark, Guid messageId)
        {
            Task <PersistedMessage> t = ((IPersist)this).PeekAndMarkAsync(q, mark, messageId);

            t.Wait();
            return(t.Result);
        }
Example #7
0
        PersistedMessage IPersist.PeekAndMarkNext(string q, PersistedMessageStatusOptions mark)
        {
            Task <PersistedMessage> t = ((IPersist)this).PeekAndMarkNextAsync(q, mark);

            t.Wait();
            return(t.Result);
        }
Example #8
0
        async Task <bool> IPersist.ToggleMarkAllAsync(string q, PersistedMessageStatusOptions newMark, PersistedMessageStatusOptions oldMark)
        {
            CancellationTokenSource cts = new CancellationTokenSource();

            return(await((IPersist)this).ToggleMarkAllAsync(q, newMark, oldMark, cts.Token));
        }
Example #9
0
        async Task <PersistedMessage> IPersist.MarkAsync(Guid id, PersistedMessageStatusOptions mark)
        {
            CancellationTokenSource cts = new CancellationTokenSource();

            return(await((IPersist)this).MarkAsync(id, mark, cts.Token));
        }
Example #10
0
        async Task <PersistedMessage> IPersist.PeekAndMarkAsync(string q, PersistedMessageStatusOptions mark, Guid messageId)
        {
            CancellationTokenSource cts = new CancellationTokenSource();

            return(await((IPersist)this).PeekAndMarkAsync(q, mark, cts.Token, messageId));
        }