我正在使用公共交通并连接到我的兔子经纪人。
string uri1 = @"rabbitmq://myusername:mypassword@myip/myvirtualhost/myqueue";
我不断收到未处理的 ConfigurationException。
在 d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\ 中的 MassTransit.ServiceContainer.Start() 处创建服务总线 {System.Collections.ListDictionaryInternal.NodeKeyValueCollection} {"Failed to start bus services"} 时引发异常ServiceContainer.cs:D:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\ServiceBus.cs 中 MassTransit.ServiceBus.Start() 的第 83 行:d:\ 中 MassTransit.Builders.ServiceBusBuilderImpl.Build() 的第 369 行BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Configuration\Builders\ServiceBusBuilderImpl.cs:D:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Configuration\ 中 MassTransit.BusConfigurators.ServiceBusConfiguratorImpl.CreateServiceBus() 的第 84 行BusConfigurators\ServiceBusConfiguratorImpl.cs:MassTransit.ServiceBusFactory 的第 171 行。d:\BuildAgent-03\work\aa063b4295dfc097\src\MassTransit\Configuration\ServiceBusFactory.cs:line 44 中的新建(操作`1 配置)
真正奇怪的是,它在不指定虚拟主机的情况下工作,但它们偏离了错误的虚拟主机。
然后我下载了 rabbitMQ 库,它使用我的凭据很好地连接到了正确的虚拟主机。这就是我知道我的凭据的方式,虚拟主机设置得很好。我什至添加了一个队列以防出现问题。Masstransit中是否存在一些错误?我真的不明白我做错了什么。我正在考虑不使用公共交通并编写我自己的轻量级版本。
我什至将其复制粘贴到https://github.com/MassTransit/MassTransit/blob/v2.7.2/src/Transports/MassTransit.Transports.RabbitMq/RabbitMqEndpointAddress.cs#L167我的解决方案以检查它是否正在修剪虚拟主机正确,它是。我真的很困惑。` static readonly Regex regex = new Regex(@"^[A-Za-z0-9- .:]+$");
public static RabbitMqEndpointAddress Parse(Uri address)
{
Guard.AgainstNull(address, "address");
if (string.Compare("rabbitmq", address.Scheme, true) != 0)
throw new RabbitMqAddressException("The invalid scheme was specified: " + address.Scheme ?? "(null)");
var connectionFactory = new ConnectionFactory
{
HostName = address.Host,
UserName = "",
Password = "",
};
if (address.IsDefaultPort)
connectionFactory.Port = 5672;
else if (!address.IsDefaultPort)
connectionFactory.Port = address.Port;
if (!address.UserInfo.IsEmpty())
{
if (address.UserInfo.Contains(":"))
{
string[] parts = address.UserInfo.Split(':');
connectionFactory.UserName = parts[0];
connectionFactory.Password = parts[1];
}
else
connectionFactory.UserName = address.UserInfo;
}
string name = address.AbsolutePath.Substring(1);
string[] pathSegments = name.Split('/');
if (pathSegments.Length == 2)
{
connectionFactory.VirtualHost = pathSegments[0];
name = pathSegments[1];
}
ushort heartbeat = address.Query.GetValueFromQueryString("heartbeat", connectionFactory.RequestedHeartbeat);
connectionFactory.RequestedHeartbeat = heartbeat;
VerifyQueueOrExchangeNameIsLegal(name);
return new RabbitMqEndpointAddress(address, connectionFactory, name);
}
static void VerifyQueueOrExchangeNameIsLegal(string path)
{
Match match = _regex.Match(path);
if (!match.Success)
throw new RabbitMqAddressException(FormatErrorMsg);
}
const string FormatErrorMsg =
"The path can be empty, or a sequence of these characters: letters, digits, hyphen, underscore, period, or colon.";
private static void Main(string[] args)
{
string uri1 = @"rabbitmq://username:password@mydomain.co.za/vhost/queue";
IServiceBus serviceBus;
var result = Parse(new Uri(uri1));
serviceBus = ServiceBusFactory.New(sbc =>
{
sbc.UseRabbitMq();
sbc.ReceiveFrom(uri1);
sbc.Subscribe(c => c.Consumer<SendEmailConsumer>());
});
IPublish publishMessage = new MassTransitPublisher(uri1);
publishMessage.Publish(new SendEmail
{
EmailFrom = "*@8.co.za",
EmailTo = "*@*.co.za",
Subject = "hello",
Body = "hello"
});
Console.ReadKey();
JobRunner jobRunner = new JobRunner();
jobRunner.Start();
Console.ReadKey();
}`
任何帮助将不胜感激,或者我可以尝试使其正常工作。