void ISubscriptionStorage.Subscribe(Address address, IEnumerable <MessageType> messageTypes) { using (var context = new SubscriptionServiceContext(client)) { foreach (var messageType in messageTypes) { try { var subscription = new Subscription { RowKey = EncodeTo64(address.ToString()), PartitionKey = messageType.ToString() }; context.AddObject(SubscriptionServiceContext.SubscriptionTableName, subscription); context.SaveChangesWithRetries(); } catch (StorageException ex) { if (ex.RequestInformation.HttpStatusCode != 409) { throw; } } } } }
void ISubscriptionStorage.Subscribe(Address address, IEnumerable<MessageType> messageTypes) { using (var context = new SubscriptionServiceContext(client)) { foreach (var messageType in messageTypes) { try { var subscription = new Subscription { RowKey = EncodeTo64(address.ToString()), PartitionKey = messageType.ToString() }; context.AddObject(SubscriptionServiceContext.SubscriptionTableName, subscription); context.SaveChangesWithRetries(); } catch (StorageException ex) { if (ex.RequestInformation.HttpStatusCode != 409) throw; } } } }
void ISubscriptionStorage.Unsubscribe(Address address, IEnumerable<MessageType> messageTypes) { using (var context = new SubscriptionServiceContext(client)) { var encodedAddress = EncodeTo64(address.ToString()); foreach (var messageType in messageTypes) { var type = messageType; var query = from s in context.Subscriptions where s.PartitionKey == type.ToString() && s.RowKey == encodedAddress select s; var subscription = query.SafeFirstOrDefault(); if(subscription != null) context.DeleteObject(subscription); context.SaveChangesWithRetries(); } } }
IEnumerable<Address> ISubscriptionStorage.GetSubscriberAddressesForMessage(IEnumerable<MessageType> messageTypes) { var subscribers = new List<Address>(); using (var context = new SubscriptionServiceContext(client)) { foreach (var messageType in messageTypes) { var type = messageType; var query = from s in context.Subscriptions where s.PartitionKey == type.ToString() select s; subscribers.AddRange(query.ToList().Select(s => Address.Parse(DecodeFrom64(s.RowKey)))); } } return subscribers; }
IEnumerable <Address> ISubscriptionStorage.GetSubscriberAddressesForMessage(IEnumerable <MessageType> messageTypes) { var subscribers = new List <Address>(); using (var context = new SubscriptionServiceContext(client)) { foreach (var messageType in messageTypes) { var type = messageType; var query = from s in context.Subscriptions where s.PartitionKey == type.ToString() select s; subscribers.AddRange(query.ToList().Select(s => Address.Parse(DecodeFrom64(s.RowKey)))); } } return(subscribers); }
void ISubscriptionStorage.Unsubscribe(Address address, IEnumerable<MessageType> messageTypes) { using (var context = new SubscriptionServiceContext(client)) { var encodedAddress = EncodeTo64(address.ToString()); foreach (var messageType in messageTypes) { var type = messageType; var query = from s in context.Subscriptions where s.PartitionKey == type.ToString() && s.RowKey == encodedAddress select s; var subscription = query .AsTableServiceQuery(context) // Fixes #191 .AsEnumerable() // Fixes #191, continuation not applied on single resultsets eventhough continuation can happen .SafeFirstOrDefault(); if(subscription != null) context.DeleteObject(subscription); context.SaveChangesWithRetries(); } } }
void ISubscriptionStorage.Unsubscribe(Address address, IEnumerable <MessageType> messageTypes) { using (var context = new SubscriptionServiceContext(client)) { var encodedAddress = EncodeTo64(address.ToString()); foreach (var messageType in messageTypes) { var type = messageType; var query = from s in context.Subscriptions where s.PartitionKey == type.ToString() && s.RowKey == encodedAddress select s; var subscription = query.FirstOrDefault(); if (subscription != null) { context.DeleteObject(subscription); } context.SaveChangesWithRetries(); } } }
void ISubscriptionStorage.Unsubscribe(Address address, IEnumerable <MessageType> messageTypes) { using (var context = new SubscriptionServiceContext(client)) { var encodedAddress = EncodeTo64(address.ToString()); foreach (var messageType in messageTypes) { var type = messageType; var query = from s in context.Subscriptions where s.PartitionKey == type.ToString() && s.RowKey == encodedAddress select s; var subscription = query .AsTableServiceQuery(context) // Fixes #191 .AsEnumerable() // Fixes #191, continuation not applied on single resultsets eventhough continuation can happen .SafeFirstOrDefault(); if (subscription != null) { context.DeleteObject(subscription); } context.SaveChangesWithRetries(); } } }