Home > database >  ASP.NET CORE combined with RabbitMq message queue
ASP.NET CORE combined with RabbitMq message queue

Time:01-07

I am using asp.net core to create a project, I want to combine rabbitmq to realize the sending and receiving of message queue.I installed rabbitmq using docker and it runs successfully.But the queue I registered in the project is not displayed on the RabbitMq management interface.

ConnectionFactory factory = new ConnectionFactory
{
    UserName = "guest",
    Password = "guest",
    HostName = "*******"
};


var connection = factory.CreateConnection();

var channel = connection.CreateModel();

channel.QueueDeclare("test", false, false, false, null);

Console.WriteLine("\nRabbitMQ enter exit to exit!");

string input;
do
{
    input = Console.ReadLine();

    var sendBytes = Encoding.UTF8.GetBytes(input);
    
    channel.BasicPublish("", "test", null, sendBytes);

} while (input.Trim().ToLower()!="exit");
channel.Close();
connection.Close();

The above is my message production code.But there is no display on my RabbitMq dashboard.

enter image description here

Check if your corresponding virtual hosts match, I set "/" here, if you are not, please add your hosts here:

enter image description here

Result:

console:

enter image description here

rabbitmq: enter image description here

  •  Tags:  
  • Related