I have this piece of code and i use rabbitmq client. i m curious if this is asynchronous or synchronous? if synchronous, how can i make it async ?
ConnectionFactory factory = new ConnectionFactory();
factory.HostName = "localhost";
using (IConnection connection = factory.CreateConnection())
using (IModel channel = connection.CreateModel())
{
channel.QueueDeclare("hello", false, false, false, null);
for (int i = 0; i < 1000; i++)
{
string message = "Hello World!";
byte[] body = System.Text.Encoding.UTF8.GetBytes(message);
channel.BasicPublish("", "hello", null, body);
}
}
See chapter 2.9 of official C# client guide:
BasicPublish is imho blocking synchronous operation.