MassTransit RabbitMQ endpoint await fails

319 views
Skip to first unread message

steve smith

unread,
Nov 9, 2017, 5:56:12 AM11/9/17
to masstransit-discuss
Here goes,

My Bus config class,
public static class BusConfigurator
    {
        public static IBusControl ConfigureBus(Action<IRabbitMqBusFactoryConfigurator, IRabbitMqHost> registrationAction = null)
        {
            return MassTransit.Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(new Uri(RabbitMqConstants.RabbitMqUri), hst =>
                {
                    hst.Username(RabbitMqConstants.UserName);
                    hst.Password(RabbitMqConstants.Password);
                });

                registrationAction?.Invoke(cfg, host);
            });
        }

    }

Constants class,

public class RabbitMqConstants
    {
        public const string RabbitMqUri = "rabbitmq://localhost/Msp";
        public const string UserName = "fake";
        public const string Password = "fake";
        public const string GetOrdersApiQueue = "Api_Queue";
        
    }

Then i have a Scheduler service (using hang fire and not quartz just as prototype.
the program class (service is a console app)
 static void Main(string[] args)
        {
            using (WebApp.Start<Startup>($"http://localhost:1223"))//NOTE:http://localhost:1223/hangfire is the actual full url to access hangfire dashboard.
            {
                //yehy! hangfire is working
                RecurringJob.AddOrUpdate(() => Console.WriteLine("Hangfire Works"), Cron.Minutely);
                Console.WriteLine("Hangfire on");
                //ok gogo gadget sendcommand!
                RecurringJob.AddOrUpdate(() => SendCommandAsync(), Cron.Minutely/*Cron.MinuteInterval(5)*/);
                
                Console.ReadKey();
            }
        }

        public static async Task<bool> SendCommandAsync()
        {
            //get the universal bus
            var bus = BusConfigurator.ConfigureBus();
            //set the Uri
            var sendToUri = new Uri($"{RabbitMqConstants.RabbitMqUri}{RabbitMqConstants.GetOrdersApiQueue}");
            //get the endpoint
            var endPoint = await bus.GetSendEndpoint(sendToUri);

            //send the command
            await endPoint.Send<IGetOrdersApiCommand>(new
            {
                Something = "gogogogo!"
            });
            
            return true;
        }

Now the issue i get is when my job is fired the endpoint await bus.GetSendEndpoint(sendToUri) never returns back,  when i look at hangfire theirs an error:

MassTransit.EndpointNotFoundException

The endpoint address specified an unknown host: rabbitmq://localhost/MspApi_QueueMassTransit.EndpointNotFoundException: The endpoint address specified an unknown host: rabbitmq://localhost/MspApi_Queue
 at
MassTransit.RabbitMqTransport.Transport.RabbitMqSendTransportProvider.GetSendTransport(Uri address)
 at
MassTransit.RabbitMqTransport.Transport.RabbitMqSendEndpointProvider.<GetSendEndpoint>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at
MassTransit.Transports.SendEndpointCache.<GetSendEndpointFromProvider>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at
MassTransit.Util.Caching.PendingValue`2.<CreateValue>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at MassTransit.Transports.SendEndpointCache.<GetSendEndpoint>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
 at System.Runtime.CompilerServices.TaskAwaiter`
1.GetResult()
 at MSP
.Service.Schedular.Program.<SendCommandAsync>d__1.MoveNext() in C:\Users\ssmith\Documents\Visual Studio 2017\Projects\MicroServicePrototype\MSP.Schedular.Service\Program.cs:line 33

Any Ideas why this is happening?  what am i missing here?






steve smith

unread,
Nov 9, 2017, 6:03:20 AM11/9/17
to masstransit-discuss
Also using masstransit nuget package version 3.5.0.0
Reply all
Reply to author
Forward
0 new messages