[HttpGet]
[Route("api/sender")]
public string Sender(string message, string hostName)
{
try
{
Send("myQ1", message, hostName);
return "successfully message sent to Queue";
}
catch (Exception ex)
{
return ex.Message;
}
}
public static void Send(string queue, string data,string hostName)
{
var factory = new ConnectionFactory() { HostName = hostName };
using (IConnection connection = factory.CreateConnection())
{
using (IModel channel = connection.CreateModel())
{
channel.QueueDeclare(queue, false, false, false, null);
channel.BasicPublish(string.Empty, queue, null, Encoding.UTF8.GetBytes(data));
}
}
}
I have configured RabbitMQ cluster on Azure AKS(Hybrid cluster Win+Linux) using helm and then deployed the above code by creating docker image using LoadBalancer Service to access the application. So, my API URL is like :
Here I am passing hostname dynamically to this API as : rabbit@my-release-rabbitmq-0.my-release-rabbitmq-headless.default.svc.cluster.local
I have port forwarded from 15672 to 3000 to access RabbitMQ Dashboard from my native computer like below image.
But not able to send the message to Queue.
So, my question is what should I pass as host name in the API I have created(above code) to send message to RabbitMQ queue