Rewrite RabbitMQ ValuesController code to support netcoreapp2.1
This commit is contained in:
Родитель
2eb9f18622
Коммит
b8a50385f6
|
@ -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!"";
|
||||
");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче