Предоставить
Код: Выделить всё
/// Program
builder.Services.AddMassTransit(x =>
{
//x.AddConsumer();
//将请求发送到指定地址,
x.AddRequestClient();
x.UsingInMemory((context, cfg) =>
{
cfg.ConfigureEndpoints(context);
});
});
/// Controllor
[Route("api/[controller]")]
[ApiController]
public class RequestController : ControllerBase
{
IRequestClient _client;
public RequestController(IRequestClient client)
{
_client = client;
}
[HttpGet("{orderId}")]
public async Task Get(string orderId, CancellationToken cancellationToken)
{
//var response = await _client.GetResponse(new { orderId }, cancellationToken);
return Ok(response.Message);
}
}
Код: Выделить всё
/// Program
builder.Services.AddMassTransit(x =>
{
x.AddRequestClient();
x.UsingInMemory((context, cfg) =>
{
cfg.ConfigureEndpoints(context);
});
});
/// Consumer
public class CheckOrderStatusConsumer :
IConsumer
{
public async Task Consume(ConsumeContext context)
{
await context.RespondAsync(new
{
OrderId = "11111",
});
}
}
Код: Выделить всё
//x.AddConsumer();
Отмена аннотации может выполняться в обычном режиме.
Извините, я не знаю английского языка. . Вопросы я задавал через переводчика
Я самоучка, поэтому могут быть непонятные выражения или непонимание бизнес-процессов. Пожалуйста, прости меня
Подробнее здесь: https://stackoverflow.com/questions/793 ... t-response
Мобильная версия