/// <summary> /// Gets the queue settings. /// </summary> /// <param name="name">The name.</param> /// <param name="arguments">The arguments.</param> /// <returns></returns> public RMQQueueSettings GetQueueSettings(string name, IDictionary <string, object> arguments = null) { var attributes = GetAttributes("queue", name); var routingKeys = new List <string>(); var queueSettings = new RMQQueueSettings(name) { QueueName = StringHelper.IfNullOrEmptyUseDefault(attributes["QueueName"], name), Exclusive = StringHelper.IfNullOrEmptyUseDefault(attributes["exclusive"], "true") == "true", Durable = StringHelper.IfNullOrEmptyUseDefault(attributes["durable"], "true") == "true", AutoDelete = StringHelper.IfNullOrEmptyUseDefault(attributes["autoDelete"], "false") == "true", Persistent = StringHelper.IfNullOrEmptyUseDefault(attributes["persistent"], "true") == "true", RoutingKeys = routingKeys, Arguments = arguments ?? new Dictionary <string, object>() }; var sRoutingKeys = StringHelper.IfNullOrEmptyUseDefault(attributes["routingKeys"], string.Empty); foreach (var routingKey in sRoutingKeys.Split(new char[] { ',' })) { routingKeys.Add(routingKey.Trim()); } if (_configNode != null) { // get arguments if they exist var argsNode = _configNode.GetConfigNode($"./queue[@name='{name}']/arguments"); if (argsNode != null) { attributes = argsNode.GetAttributes(); foreach (var key in attributes.AllKeys) { if (!queueSettings.Arguments.ContainsKey(key)) { queueSettings.Arguments[key] = attributes[key]; } } } // get consumer info if it exists var consumerNode = _configNode.GetConfigNode($"./queue[@name='{name}']/consumer"); if (consumerNode != null) { attributes = consumerNode.GetAttributes(); queueSettings.ConsumerSettings.Tag = StringHelper.IfNullOrEmptyUseDefault(attributes["tag"], Guid.NewGuid().ToString()); queueSettings.ConsumerSettings.Exclusive = StringHelper.IfNullOrEmptyUseDefault(attributes["exclusive"], "true") == "true"; queueSettings.ConsumerSettings.NoAck = StringHelper.IfNullOrEmptyUseDefault(attributes["noAck"], "true") == "true"; queueSettings.ConsumerSettings.NoLocal = StringHelper.IfNullOrEmptyUseDefault(attributes["noLocal"], "true") == "true"; } } return(queueSettings); }
/// <summary> /// Gets the node child attributes. /// </summary> /// <param name="node">The node.</param> /// <param name="parentXPath">The parent x path.</param> /// <returns></returns> public static NodeChildAttributes GetNodeChildAttributes(IConfigNode node, string parentXPath) { var nca = new NodeChildAttributes(); var pnode = node.GetConfigNode(parentXPath); if (pnode != null) { nca.ParentAttributes.NodeName = pnode.Name; nca.ParentAttributes.Attributes.Add(pnode.GetAttributes()); var children = pnode.GetConfigNodes("./*"); foreach (var cnode in children) { var na = new NodeAttributes() { NodeName = cnode.Name }; na.Attributes.Add(cnode.GetAttributes()); nca.ChildAttributes.Add(na); } } return(nca); }