/// <summary>
        /// Registers the message queue, its creation specified via the factory method
        /// MessageQueueCreatorDelegate, with the provided name in the application context
        /// </summary>
        /// <param name="messageQueueObjectName">Name of the message queue object.</param>
        /// <param name="messageQueueCreatorDelegate">The message queue creator delegate.</param>
        public void RegisterMessageQueue(string messageQueueObjectName,
                                         MessageQueueCreatorDelegate messageQueueCreatorDelegate)
        {
            MessageQueueFactoryObject mqfo = new MessageQueueFactoryObject();

            mqfo.MessageCreatorDelegate = messageQueueCreatorDelegate;
            applicationContext.ObjectFactory.RegisterSingleton(messageQueueObjectName, mqfo);
            IDictionary <string, MessageQueueMetadataCache> caches = applicationContext.GetObjects <MessageQueueMetadataCache>();

            foreach (KeyValuePair <string, MessageQueueMetadataCache> entry in caches)
            {
                entry.Value.Insert(mqfo.Path, new MessageQueueMetadata(mqfo.RemoteQueue, mqfo.RemoteQueueIsTransactional));
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes the cache.
        /// </summary>
        public void Initialize()
        {
            IDictionary <string, MessageQueueFactoryObject> messageQueueDictionary = configurableApplicationContext.GetObjects <MessageQueueFactoryObject>();

            lock (itemStore.SyncRoot)
            {
                foreach (KeyValuePair <string, MessageQueueFactoryObject> entry in messageQueueDictionary)
                {
                    MessageQueueFactoryObject mqfo = entry.Value;
                    if (mqfo != null)
                    {
                        if (mqfo.Path != null)
                        {
                            Insert(mqfo.Path,
                                   new MessageQueueMetadata(mqfo.RemoteQueue, mqfo.RemoteQueueIsTransactional));
                        }
                        else
                        {
                            #region Logging
                            if (LOG.IsWarnEnabled)
                            {
                                LOG.Warn(
                                    "Path for MessageQueueFactoryObject named [" +
                                    mqfo.ObjectName + "] is null, so can't cache its metadata.");
                            }
                            #endregion
                        }
                    }
                    else
                    {
                        // This would indicate some bug in GetObjectsOfType
                        LOG.Error("Unexpected type of " + entry.Value.GetType() + " was given as candidate for caching MessageQueueMetadata.");
                    }
                }
                isInitialized = true;
            }
        }