Yes
Yes
static void Main()
{
var mtBus = Bus.Factory.CreateUsingRabbitMq(busFactoryConfig =>
{
busFactoryConfig.Host(new Uri("rabbitmq://localhost"), hostConfig =>
{
hostConfig.Username("admin");
hostConfig.Password("admin");
});
});
mtBus.Start();
//should raise exception
var result = mtBus.GetSendEndpoint(new Uri("rabbitmq://localhost/testQueue?queue=testQueue&bind=false")).GetAwaiter().GetResult();
}
EndpointNotFoundException because testQueue does not exist on RabbitMQ. No vhost is configured.
GetSendEndpoint should throw an EndpointNotFoundException because testQueue does not exist on RabbitMQ.
It just continues and creates an exchange with name testQueue with no bindings, messages are discarded.
Run a local RabbitMQ server and create a console app with code below:
static void Main()
{
var mtBus = Bus.Factory.CreateUsingRabbitMq(busFactoryConfig =>
{
busFactoryConfig.Host(new Uri("rabbitmq://localhost"), hostConfig =>
{
hostConfig.Username("admin");
hostConfig.Password("admin");
});
});
mtBus.Start();
//should raise exception
var result = mtBus.GetSendEndpoint(new Uri("rabbitmq://localhost/testQueue?queue=testQueue&bind=false")).GetAwaiter().GetResult();
}
GetSendEndpoint(new Uri("rabbitmq://localhost/testQueue?queue=testQueue&bind=false"));
Will create the exchange queue. The proper syntax for this address is:
var result = mtBus.GetSendEndpoint(new Uri("rabbitmq://localhost/testQueue"));
GetSendEndpoint(new Uri("rabbitmq://localhost/testQueue?queue=testQueue&bind=false"));Will create the exchange queue. The proper syntax for this address is:
var result = mtBus.GetSendEndpoint(new Uri("rabbitmq://localhost/testQueue"));
Exchange is still created in the latter way. Anyway, my question was different...
Expected Behavior
GetSendEndpoint should throw an EndpointNotFoundException because testQueue does not exist on RabbitMQ.
In response to our chat on Gitter; Indeed the behavior was always the same, GetSendEnpoint never threw an exception in previous versions of MassTransit. I'm just questioning the design, A Send should always put the given message in the given queue right? If queue/exchange doesn't exist, then an exception should be thrown in my opinion. Just like the mandatory parameter when doing a publish
Indeed, weird behaviour.
Any update?
There is no update. If you use "queue:name" it will bind and create the queue. If you use "exchange:name" it will only create the exchange if it doesn't exist.
There is no update. If you use "queue:name" it will bind and create the queue. If you use "exchange:name" it will only create the exchange if it doesn't exist.
Can you please elaborate? How can I force the queue to be created when using GetSendEndpoint?
If you鈥檙e using RabbitMQ, and pass queue:name as the destination address, it will create the queue using the default queue parameters (durable=true, autoDelete=false).
If you鈥檙e using RabbitMQ, and pass
queue:nameas the destination address, it will create the queue using the default queue parameters (durable=true, autoDelete=false).
Oh cool, just discovered short addresses, coming from an older version of MT. For others like me:
var result = mtBus.GetSendEndpoint(new Uri("queue:testQueue"));
Actually, I support the original question: imho, an exception should be thrown when a non-existing queue or exchange is being referenced. This would prevent MassTransit from creating multiple queues in case wrong queue- or exchange names are being used.
This would improve how the messaging infrastructure can be managed and 'observed'. When it is required to have your queues etc... defined upfront, it's easier for a devops team to define alerts, etc... since they know which entities exist.
Also, it wouldn't require MassTransit to have 'manage' rights on the messaging solution.
Well that isn't how MassTransit works.
Is there a way to query the queue's / exchanges that already exist via MassTransit ? In that case, I could opt to throw an exception myself if a non-existing queue is used.
No, you'd have to use RabbitMQ's API. Or look at something like HareDu to query what's available.
I have no idea why you'd do that though, just pay attention to the queue names you're using.
Most helpful comment
Exchange is still created in the latter way. Anyway, my question was different...
Expected Behavior
GetSendEndpoint should throw an EndpointNotFoundException because testQueue does not exist on RabbitMQ.
In response to our chat on Gitter; Indeed the behavior was always the same, GetSendEnpoint never threw an exception in previous versions of MassTransit. I'm just questioning the design, A
Sendshould always put the given message in the given queue right? If queue/exchange doesn't exist, then an exception should be thrown in my opinion. Just like themandatoryparameter when doing a publish