我正在尝试使用 Web API 和 Rabbit MQ 消息代理来实现发布/订阅架构。
我的解决方案中有两个项目:发布者和订阅者。
发布正在成功实施,但我在我的网站中找不到位置
订阅者项目从队列中读取已发布的消息。
我的两个项目都是.Net Core ASP WEB API
提前致谢
使用ConfigureServices方法中的AddSingleton方法将rabbitMq注册为HostedService。 IHostedService 内部调用 ApplicationGetStarted 事件。于是兔子开始在那里听
public void ConfigureServices(IServiceCollection services)
{
services.AddMassTransit(x =>
{
x.UsingRabbitMq();
});
// OPTIONAL, but can be used to configure the bus options
services.AddOptions<MassTransitHostOptions>()
.Configure(options =>
{
// if specified, waits until the bus is started before
// returning from IHostedService.StartAsync
// default is false
options.WaitUntilStarted = true;
// if specified, limits the wait time when starting the bus
options.StartTimeout = TimeSpan.FromSeconds(10);
// if specified, limits the wait time when stopping the bus
options.StopTimeout = TimeSpan.FromSeconds(30);
});
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)