示例#1
0
        private static void SetupPersistentSubscription(Guid?subscriptionId, string profileName, StreamId streamId,
                                                        string aggregateType, bool isConnected,
                                                        IPersistentStreamSubscriptionConnection connection,
                                                        ISubscriptionRootManager rootManager,
                                                        ISubscriptionManager manager)
        {
            if (!subscriptionId.HasValue)
            {
                var subscriptionBase   = rootManager.CreatePersistentSubscription(profileName).Result;
                var connectionSettings = new PersistentStreamSubscriptionConnectionSettings(subscriptionBase.SubscriptionId, profileName, streamId, aggregateType);
                manager.Add(subscriptionBase.SubscriptionId, connection, connectionSettings).Wait();
                rootManager.StartSubscription(subscriptionBase.SubscriptionId).Wait();
                //manager.Connect(subscriptionBase.SubscriptionId).Wait();
                return;
            }
            else
            {
                var connectionSettings = new PersistentStreamSubscriptionConnectionSettings(subscriptionId.Value, profileName, streamId, aggregateType);
                manager.Add(subscriptionId.Value, connection, connectionSettings).Wait();

                if (isConnected)
                {
                    manager.Connect(subscriptionId.Value).Wait();
                }
            }
        }
示例#2
0
        public async Task <Unit> Handle(StartSubscriptionCommand request, CancellationToken cancellationToken)
        {
            await _rootManager.StartSubscription(request.SubscriptionId);

            return(Unit.Value);
        }