question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetSendEndpoint should raise exception on non-existing queue

See original GitHub issue

Is this a bug report?

Yes

Can you also reproduce the problem with the latest version?

Yes

Environment

  1. Operating system: Windows 10 Enterprise 64-bit
  2. Visual Studio version: VS 2017
  3. Dotnet version: .NET Framework 4.6.2

Steps to Reproduce

  1. Have a RabbitMQ running locally
  2. Create a new Console application
  3. Paste following code:
        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();
        }
  1. the last line, GetSendEndpoint should throw an EndpointNotFoundException because testQueue does not exist on RabbitMQ.

No vhost is configured.

Expected Behavior

GetSendEndpoint should throw an EndpointNotFoundException because testQueue does not exist on RabbitMQ.

Actual Behavior

It just continues and creates an exchange with name testQueue with no bindings, messages are discarded.

Reproducible Demo

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();
        }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ozdotnetcommented, Feb 18, 2021
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

1reaction
youqingzcommented, May 6, 2020

If you’re using RabbitMQ, and pass queue:name as 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"));

Read more comments on GitHub >

github_iconTop Results From Across the Web

MassTransit RabbitMq Sending Messages
I am not able to figure out on how to specify the Exchange and Queue in my GetSendEndpoint()) task when sending / publishing...
Read more >
Exceptions
With this consumer, an ADOException can be thrown, say there is a deadlock or the SQL server is unavailable. In this case, the...
Read more >
Producers
Producers. An application or service can produce messages using two different methods. A message can be sent or a message can be published....
Read more >
MassTransit Exception Handling, Retry Middleware - YouTube
Episode Five describes how to configure consumers and sagas to retry exceptions using definitions. The error queue is covered, including how ...
Read more >
MassTransit Send vs. Publish
This tutorial will look at what is happening with the two different message types. To follow along, download the completed project here.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found