Ejemplo n.º 1
0
        private IMessageConsumer GetCachedConsumer(Destination destination, string selector, bool noLocal, string subscription)
        {
            object           cacheKey = new ConsumerCacheKey(destination, selector, noLocal, null);
            IMessageConsumer consumer = (IMessageConsumer)cachedConsumers[cacheKey];

            if (consumer != null)
            {
                if (LOG.IsDebugEnabled)
                {
                    LOG.Debug("Found cached EMS MessageConsumer for destination [" + destination + "]: " + consumer);
                }
            }
            else
            {
                if (destination is Topic)
                {
                    consumer = (subscription != null
                                    ? target.CreateDurableSubscriber((Topic)destination, subscription, selector, noLocal)
                                    : target.CreateConsumer(destination, selector, noLocal));
                }
                else
                {
                    consumer = target.CreateConsumer(destination, selector);
                }
                if (LOG.IsDebugEnabled)
                {
                    LOG.Debug("Creating cached EMS MessageConsumer for destination [" + destination + "]: " + consumer);
                }
                cachedConsumers[cacheKey] = consumer;
            }
            return(new CachedMessageConsumer(consumer));
        }
Ejemplo n.º 2
0
        private void LogicalClose()
        {
            // Preserve rollback-on-close semantics.
            if (this.transactionOpen && this.target.Transacted)
            {
                this.transactionOpen = false;
                this.target.Rollback();
            }

            // Physically close durable subscribers at time of Session close call.
            IList ToRemove = new ArrayList();

            foreach (DictionaryEntry dictionaryEntry in cachedConsumers)
            {
                ConsumerCacheKey key = (ConsumerCacheKey)dictionaryEntry.Key;
                if (key.Subscription != null)
                {
                    ((IMessageConsumer)dictionaryEntry.Value).Close();
                    ToRemove.Add(key);
                }
            }
            foreach (ConsumerCacheKey key in ToRemove)
            {
                cachedConsumers.Remove(key);
            }

            // Allow for multiple close calls...
            if (!sessionList.Contains(this))
            {
                #region Logging

                if (LOG.IsDebugEnabled)
                {
                    LOG.Debug("Returning cached Session: " + target);
                }

                #endregion

                sessionList.Add(this); //add to end of linked list.
            }
        }
Ejemplo n.º 3
0
 protected bool Equals(ConsumerCacheKey consumerCacheKey)
 {
     if (consumerCacheKey == null)
     {
         return(false);
     }
     if (!Equals(destination, consumerCacheKey.destination))
     {
         return(false);
     }
     if (!ObjectUtils.NullSafeEquals(selector, consumerCacheKey.selector))
     {
         return(false);
     }
     if (!Equals(noLocal, consumerCacheKey.noLocal))
     {
         return(false);
     }
     if (!ObjectUtils.NullSafeEquals(subscription, consumerCacheKey.subscription))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
 protected bool Equals(ConsumerCacheKey consumerCacheKey)
 {
     if (consumerCacheKey == null) return false;
     if (!Equals(destination, consumerCacheKey.destination)) return false;
     if (!ObjectUtils.NullSafeEquals(selector, consumerCacheKey.selector)) return false;
     if (!Equals(noLocal, consumerCacheKey.noLocal)) return false;
     if (!ObjectUtils.NullSafeEquals(subscription, consumerCacheKey.subscription)) return false;
     return true;
 }
Ejemplo n.º 5
0
 private IMessageConsumer GetCachedConsumer(Destination destination, string selector, bool noLocal, string subscription)
 {
     object cacheKey = new ConsumerCacheKey(destination, selector, noLocal, null);
     IMessageConsumer consumer = (IMessageConsumer)cachedConsumers[cacheKey];
     if (consumer != null)
     {
         if (LOG.IsDebugEnabled)
         {
             LOG.Debug("Found cached EMS MessageConsumer for destination [" + destination + "]: " + consumer);
         }
     }
     else
     {
         if (destination is Topic)
         {
             consumer = (subscription != null
                             ? target.CreateDurableSubscriber((Topic)destination, subscription, selector, noLocal)
                             : target.CreateConsumer(destination, selector, noLocal));
         }
         else
         {
             consumer = target.CreateConsumer(destination, selector);
         }
         if (LOG.IsDebugEnabled)
         {
             LOG.Debug("Creating cached EMS MessageConsumer for destination [" + destination + "]: " + consumer);
         }
         cachedConsumers[cacheKey] = consumer;
     }
     return new CachedMessageConsumer(consumer);
 }