/// <summary> /// Create queues required by Burrow.RPC library /// </summary> /// <param name="connectionString"></param> /// <param name="createExchangesAndQueues"></param> public void CreateQueues(string connectionString, Action<IModel> createExchangesAndQueues) { var clusterConnections = connectionString.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (clusterConnections.Length > 1) { Global.DefaultWatcher.InfoFormat("Found multiple Connection String, will use '{0}' to setup queues", clusterConnections[0]); } ConnectionString connectionValues = clusterConnections.Length > 1 ? new ConnectionString(clusterConnections[0]) : new ConnectionString(connectionString); var connectionFactory = new ManagedConnectionFactory { HostName = connectionValues.Host, Port = connectionValues.Port, VirtualHost = connectionValues.VirtualHost, UserName = connectionValues.UserName, Password = connectionValues.Password, }; using (var connection = connectionFactory.CreateConnection()) { using (var model = connection.CreateModel()) { try { createExchangesAndQueues(model); } catch (OperationInterruptedException oie) { if (oie.ShutdownReason.ReplyText.StartsWith("PRECONDITION_FAILED - ")) { Global.DefaultWatcher.ErrorFormat(oie.ShutdownReason.ReplyText); } else { Global.DefaultWatcher.Error(oie); } } catch (Exception ex) { Global.DefaultWatcher.Error(ex); } } } }