void ISubscriptionStorage.Subscribe(Address address, IEnumerable<string> messageTypes) { using (var transaction = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted })) using (var session = subscriptionStorageSessionProvider.OpenSession()) { foreach (var messageType in messageTypes) { var subscription = new Subscription { SubscriberEndpoint = address.ToString(), MessageType = messageType }; if (session.Get<Subscription>(subscription) == null) session.Save(subscription); } transaction.Complete(); } }
/// <summary> /// Adds the given subscription to the DB. /// Method checks for existing subcriptions to prevent duplicates /// </summary> /// <param name="client"></param> /// <param name="messageTypes"></param> void ISubscriptionStorage.Subscribe(string client, IEnumerable<string> messageTypes) { using (var session = subscriptionStorageSessionProvider.OpenSession()) using(var transaction = new TransactionScope()) { foreach (var messageType in messageTypes) { var subscription = new Subscription { SubscriberEndpoint = client, MessageType = messageType }; if (session.Get<Subscription>(subscription) == null) session.Save(subscription); } transaction.Complete(); } }
/// <summary> /// Adds the given subscription to the DB. /// Method checks for existing subcriptions to prevent duplicates /// </summary> /// <param name="client"></param> /// <param name="messageTypes"></param> public void Subscribe(string client, IList<string> messageTypes) { using (var session = sessionSource.CreateSession()) using(var transaction = new TransactionScope()) { foreach (var messageType in messageTypes) { var subscription = new Subscription { SubscriberEndpoint = client, MessageType = messageType }; if (session.Get<Subscription>(subscription) == null) session.Save(subscription); } transaction.Complete(); } }