我有这段代码,我使用rabbitmq 客户端。我很好奇这是异步的还是同步的?如果是同步的,我怎样才能让它异步?
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);
}
}