Rewrite RabbitMQ ValuesController code to support netcoreapp2.1

This commit is contained in:
Chris Cheetham 2021-05-29 11:26:35 -04:00
Родитель 2eb9f18622
Коммит b8a50385f6
2 изменённых файлов: 64 добавлений и 60 удалений

Просмотреть файл

@ -120,8 +120,9 @@ namespace Company.WebApplication1.Controllers
#if (RabbitMqOption)
public ActionResult<string> Get()
{
using var connection = _factory.CreateConnection();
using var channel = connection.CreateModel();
using (var connection = _factory.CreateConnection())
using (var channel = connection.CreateModel())
{
// the queue
channel.QueueDeclare(
queue: QueueName,
@ -152,6 +153,7 @@ namespace Company.WebApplication1.Controllers
body: body);
Thread.Sleep(1000);
}
}
return "Wrote 5 message to the info log. Have a look!";
#elif (RedisOption)

Просмотреть файл

@ -58,8 +58,9 @@ public ValuesController(ILogger<ValuesController> logger, [FromServices] Connect
[HttpGet]
public ActionResult<string> Get()
{
using var connection = _factory.CreateConnection();
using var channel = connection.CreateModel();
using (var connection = _factory.CreateConnection())
using (var channel = connection.CreateModel())
{
// the queue
channel.QueueDeclare(
queue: QueueName,
@ -90,6 +91,7 @@ public ActionResult<string> Get()
body: body);
Thread.Sleep(1000);
}
}
return ""Wrote 5 message to the info log. Have a look!"";
");
}