Esempio n. 1
0
 private void AsyncHandlesMessage(TMessage message, InMemoryMessageSubscription <TMessage> subscription)
 {
     Task.Factory.StartNew(() =>
     {
         subscription.MessageHandler(message);
     });
 }
Esempio n. 2
0
        private void RemoveSubscription(InMemoryMessageSubscription <TMessage> subscription)
        {
            if (subscription == null)
            {
                return;
            }

            Log.Debug("Acquired lock to ActiveSubscriptions at method RemoveSubscription(...)");
            lock (ActiveSubscriptions)
            {
                ActiveSubscriptions.Remove(new Tuple <Type, SubscriptionId>(subscription.MessageType, subscription.SubscriptionId));
            }
            Log.Debug("Released lock to ActiveSubscriptions at method RemoveSubscription(...)");
        }
Esempio n. 3
0
 private InMemoryMessageSubscription <TMessage> ExistingSubscriptionFor(Type messageType, SubscriptionId subscriptionId)
 {
     Log.Debug("Acquired lock to ActiveSubscriptions at method ExistingSubscriptionFor(...)");
     try
     {
         lock (ActiveSubscriptions)
         {
             InMemoryMessageSubscription <TMessage> subscription = null;
             ActiveSubscriptions.TryGetValue(new Tuple <Type, SubscriptionId>(messageType, subscriptionId), out subscription);
             return(subscription);
         }
     }
     catch (Exception e)
     {
         Log.Error(String.Format("Exception at method ExistingSubscriptionFor(...) - messageType '{0}' subscription '{1}'", messageType, subscriptionId), e);
         throw e;
     }
     finally
     {
         Log.Debug("Released lock to ActiveSubscriptions at method ExistingSubscriptionFor(...)");
     }
 }
Esempio n. 4
0
        private InMemoryMessageSubscription <TMessage> NewSubscribeSubscription(Type messageType, SubscriptionId subscriptionId, Action <TMessage> messageHandler)
        {
            var subscription = new InMemoryMessageSubscription <TMessage>(messageType, subscriptionId, messageHandler);

            return(subscription);
        }