示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RMQConfigurationManager"/> class.
 /// </summary>
 /// <param name="configPath">The configuration path.</param>
 public RMQConfigurationManager(string configPath = null)
 {
     if (configPath == null)
     {
         try
         {
             var xmlConfigSection = (XmlNode)ConfigurationManager.GetSection("rmqSettings");
             if (xmlConfigSection != null)
             {
                 _configNode     = new ConfigNode(xmlConfigSection);
                 _nodeAttributes = ConfigHelper.GetNodeChildAttributes(_configNode, ".");
             }
         }
         catch (ConfigurationErrorsException)
         {
             _nodeAttributes = new NodeChildAttributes();
         }
     }
     else
     {
         using (var configContainer = new ConfigContainer(configPath, "./rmqSettings"))
         {
             _configNode     = configContainer.Node;
             _nodeAttributes = ConfigHelper.GetNodeChildAttributes(_configNode, ".");
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProviderClassFactory"/> class.
 /// </summary>
 /// <param name="attributes">The attributes.</param>
 /// <param name="attributeNodeName">Name of the attribute node.</param>
 public ProviderClassFactory(NodeChildAttributes attributes, string attributeNodeName = "provider")
 {
     Disposed           = false;
     Attributes         = attributes;
     _attributeNodeName = attributeNodeName;
     _configContainer   = null;
     _configSection     = null;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AMQConfigurationManager"/> class.
        /// </summary>
        /// <param name="attributes">The attributes.</param>
        public AMQConfigurationManager(IEnumerable <AMQConnectionSettings> connections, IEnumerable <AMQDestinationSettings> destinations = null)
        {
            NodeAttributes = new NodeChildAttributes();
            NodeAttributes.ParentAttributes.NodeName = "amqSettings";

            if (connections != null)
            {
                foreach (var connection in connections)
                {
                    var childNode = new NodeAttributes()
                    {
                        NodeName   = "connectionSettings",
                        Attributes = new NameValueCollection()
                    };

                    childNode.Attributes["name"]             = connection.Name;
                    childNode.Attributes["username"]         = connection.Username;
                    childNode.Attributes["password"]         = connection.Password;
                    childNode.Attributes["uri"]              = connection.Uri;
                    childNode.Attributes["asyncSend"]        = connection.AsyncSend ? "true" : "false";
                    childNode.Attributes["delayOnReconnect"] = connection.DelayOnReconnect.ToString();

                    NodeAttributes.ChildAttributes.Add(childNode);
                }
            }

            if (destinations != null)
            {
                foreach (var destination in destinations)
                {
                    var childNode = new NodeAttributes()
                    {
                        NodeName   = "destinationSettings",
                        Attributes = new NameValueCollection()
                    };

                    childNode.Attributes["name"]         = destination.Name;
                    childNode.Attributes["selector"]     = destination.Selector;
                    childNode.Attributes["subscriberId"] = destination.SubscriberId;
                    childNode.Attributes["path"]         = destination.Path;
                    childNode.Attributes["deliveryMode"] = destination.DeliveryMode.ToString().ToLower();
                    childNode.Attributes["ackMode"]      = destination.AckMode.ToString().ToLower();
                    childNode.Attributes["durable"]      = destination.Durable ? "true" : "false";

                    NodeAttributes.ChildAttributes.Add(childNode);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Reloads the publishers.
        /// </summary>
        /// <param name="nodeChildAttributes">The node child attributes.</param>
        protected void ReloadPublishers(NodeChildAttributes nodeChildAttributes)
        {
            lock (_publishers)
            {
                FreePublishers();

                if (Mode == PublisherManagerMode.Off)
                {
                    return;
                }

                var factory = new ProviderClassFactory(nodeChildAttributes, "publisher");

                foreach (NodeAttributes attribute in nodeChildAttributes.ChildAttributes)
                {
                    if (StringHelper.IfNullOrEmptyUseDefault(attribute.Attributes["mode"], "on") != "on")
                    {
                        continue;
                    }

                    var publisher = factory.CreateInstance <IExceptionPublisher>(attribute.Attributes["name"]);
                    if (publisher == null)
                    {
                        continue;
                    }

                    var newPublisher = new PublisherInfo()
                    {
                        PublisherAttributes = attribute,
                        Publisher           = publisher
                    };

                    _publishers.Add(newPublisher);
                }
            }
        }