public void InitialzeMessageQueueMetadata()
        {
            MessageQueueMetadataCache cache = new MessageQueueMetadataCache(applicationContext);

            Assert.AreEqual(0, cache.Count);
            cache.Initialize();
            Assert.IsTrue(cache.Initalized);
            Assert.AreEqual(4, cache.Count);
            MessageQueueMetadata md = cache.Get(@".\Private$\testqueue");

            cache.Remove(@".\Private$\testqueue");
            Assert.AreEqual(3, cache.Count);
            Assert.IsNull(cache.Get(@".\Private$\testqueue"));

            string[] paths = new string[]
            {
                @".\Private$\testtxqueue",
                @"FormatName:Direct=TCP:192.168.1.105\Private$\testtxqueue",
                @"FormatName:Direct=TCP:192.168.1.105\Private$\testqueue"
            };

            Assert.That(paths, Is.EquivalentTo(cache.Paths));
            paths = new string[] { @".\Private$\testtxqueue", @"FormatName:Direct=TCP:192.168.1.105\Private$\testtxqueue" };
            cache.RemoveAll(paths);
            Assert.AreEqual(1, cache.Count);
            cache.Clear();
            Assert.AreEqual(0, cache.Count);
        }
        public void InitialzeMessageQueueMetadata()
        {
            MessageQueueMetadataCache cache = new MessageQueueMetadataCache(applicationContext);
            Assert.AreEqual(0, cache.Count);
            cache.Initialize();
            Assert.IsTrue(cache.Initalized);
            Assert.AreEqual(4, cache.Count);
            MessageQueueMetadata md = cache.Get(@".\Private$\testqueue");
            cache.Remove(@".\Private$\testqueue");
            Assert.AreEqual(3, cache.Count);
            Assert.IsNull(cache.Get(@".\Private$\testqueue"));

            string[] paths = new string[]
                            {
                                @".\Private$\testtxqueue",
                                @"FormatName:Direct=TCP:192.168.1.105\Private$\testtxqueue",
                                @"FormatName:Direct=TCP:192.168.1.105\Private$\testqueue"
                            };

            Assert.That(paths, Is.EquivalentTo(cache.Paths));
            paths = new string[] {@".\Private$\testtxqueue", @"FormatName:Direct=TCP:192.168.1.105\Private$\testtxqueue"};
            cache.RemoveAll(paths);
            Assert.AreEqual(1, cache.Count);
            cache.Clear();
            Assert.AreEqual(0, cache.Count);
        }
Ejemplo n.º 3
0
        protected virtual void CreateDefaultMetadataCache()
        {
            if (metadataCache == null)
            {
                if (applicationContext.ContainsObject(METADATA_CACHE_NAME))
                {
                    metadataCache = applicationContext.GetObject(METADATA_CACHE_NAME) as MessageQueueMetadataCache;
                }
                else
                {
                    metadataCache = new MessageQueueMetadataCache();
                    if (ApplicationContext != null)
                    {
                        metadataCache.ApplicationContext = ApplicationContext;
                        metadataCache.AfterPropertiesSet();
                        metadataCache.Initialize();
                        applicationContext.ObjectFactory.RegisterSingleton("__MessageQueueMetadataCache__",
                                                                           metadataCache);
                    }
                    else
                    {
                        #region Logging

                        if (LOG.IsWarnEnabled)
                        {
                            LOG.Warn(
                                "The ApplicationContext property has not been set, so the MessageQueueMetadataCache can not be automatically generated.  " +
                                "Please explictly set the MessageQueueMetadataCache using the property MetadataCache or set the ApplicationContext property.  " +
                                "This will only effect the use of MessageQueueTemplate when publishing to remote queues.");
                        }

                        #endregion
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected virtual void CreateDefaultMetadataCache()
        {
            if (metadataCache == null)
            {
                if (applicationContext.ContainsObject(METADATA_CACHE_NAME))
                {
                    metadataCache = applicationContext.GetObject(METADATA_CACHE_NAME) as MessageQueueMetadataCache;
                }
                else
                {
                    metadataCache = new MessageQueueMetadataCache();
                    if (ApplicationContext != null)
                    {
                        metadataCache.ApplicationContext = ApplicationContext;
                        metadataCache.AfterPropertiesSet();
                        metadataCache.Initialize();
                        applicationContext.ObjectFactory.RegisterSingleton("__MessageQueueMetadataCache__",
                                                                           metadataCache);
                    }
                    else
                    {
                        #region Logging

                        if (LOG.IsWarnEnabled)
                        {
                            LOG.Warn(
                                "The ApplicationContext property has not been set, so the MessageQueueMetadataCache can not be automatically generated.  " +
                                "Please explictly set the MessageQueueMetadataCache using the property MetadataCache or set the ApplicationContext property.  " +
                                "This will only effect the use of MessageQueueTemplate when publishing to remote queues.");
                        }

                        #endregion
                    }
                }
            }
        }