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(); } } }
public void Subscribe(Message request) { try { var subscription = SubscriptionRequest.Parse(XElement.Parse(request.GetReaderAtBodyContents().ReadOuterXml())); _subscriptionManager.Add(subscription); } catch (Exception ex) { throw EpcisFault.Create(ex); } }