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); }); }
}
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"; }
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; }
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?