General.Web/Controllers/API/RabbitMQServiceController.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using EasyNetQ;
using General.Mvc.Models.RabbitMQ;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace General.Mvc.Controllers.API
{
[Route("api/[controller]/[action]")]
[ApiController]
public class RabbitMQServiceController : ControllerBase
{
private readonly IBus bus;
public RabbitMQServiceController(IBus bus)
{
this.bus = bus;
}
[HttpGet]
public async Task<string> SendMessage()
{
Random r = new Random();
ClientMessage message = new ClientMessage
{
ClientId = 1,
ClientName = "hacker" + r.Next(1, 9999),
Sex = "男",
Age = 29,
SmokerCode = "N",
Education = "Master",
YearIncome = 100000
};
await bus.PublishAsync(message);
return "MQ发送消息成功~~~~";
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
