示例#1
0
        private void AckMessage(HttpEntityManager http, UriTemplateMatch match)
        {
            if (_httpForwarder.ForwardRequest(http))
            {
                return;
            }
            var envelope  = new NoopEnvelope();
            var groupname = match.BoundVariables["subscription"];
            var stream    = match.BoundVariables["stream"];
            var messageId = match.BoundVariables["messageId"];
            var id        = Guid.NewGuid();

            if (!Guid.TryParse(messageId, out id))
            {
                http.ReplyStatus(HttpStatusCode.BadRequest, "messageid should be a properly formed guid",
                                 exception => { });
                return;
            }

            var cmd = new ClientMessage.PersistentSubscriptionAckEvents(
                Guid.NewGuid(),
                Guid.NewGuid(),
                envelope,
                BuildSubscriptionGroupKey(stream, groupname),
                new[] { id },
                http.User);

            Publish(cmd);
            http.ReplyStatus(HttpStatusCode.Accepted, "", exception => { });
        }
示例#2
0
        private void AckMessages(HttpEntityManager http, UriTemplateMatch match)
        {
            var envelope   = new NoopEnvelope();
            var groupname  = match.BoundVariables["subscription"];
            var stream     = match.BoundVariables["stream"];
            var messageIds = match.BoundVariables["messageIds"];
            var ids        = new List <Guid>();

            foreach (var messageId in messageIds.Split(new[] { ',' }))
            {
                Guid id;
                if (!Guid.TryParse(messageId, out id))
                {
                    http.ReplyStatus(HttpStatusCode.BadRequest, "messageid should be a properly formed guid", exception => { });
                    return;
                }
                ids.Add(id);
            }

            var cmd = new ClientMessage.PersistentSubscriptionAckEvents(
                Guid.NewGuid(),
                Guid.NewGuid(),
                envelope,
                BuildSubscriptionGroupKey(stream, groupname),
                ids.ToArray(),
                http.User);

            Publish(cmd);
            http.ReplyStatus(HttpStatusCode.Accepted, "", exception => { });
        }
        public void Handle(ClientMessage.PersistentSubscriptionAckEvents message)
        {
            if (!_started)
            {
                return;
            }
            PersistentSubscription subscription;

            if (_subscriptionsById.TryGetValue(message.SubscriptionId, out subscription))
            {
                subscription.AcknowledgeMessagesProcessed(message.CorrelationId, message.ProcessedEventIds);
            }
        }
示例#4
0
        public void NotifyEventsProcessed(Guid[] processedEvents)
        {
            Ensure.NotNull(processedEvents, "processedEvents");
            var dto = new ClientMessage.PersistentSubscriptionAckEvents(
                _subscriptionId,
                processedEvents.Select(x => x.ToByteArray()).ToArray());

            var package = new TcpPackage(TcpCommand.PersistentSubscriptionAckEvents,
                                         _userCredentials != null ? TcpFlags.Authenticated : TcpFlags.None,
                                         _correlationId,
                                         _userCredentials != null ? _userCredentials.Username : null,
                                         _userCredentials != null ? _userCredentials.Password : null,
                                         dto.Serialize());

            EnqueueSend(package);
        }