using Furion; using Furion.EventBus; using Microsoft.Extensions.DependencyInjection; using RabbitMQ.Client; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace FlexJobApi.Core { /// /// 事件总线 /// public class EventBusServiceComponent : IServiceComponent { public void Load(IServiceCollection services, ComponentContext componentContext) { services.AddEventBus(options => { // 创建连接工厂 var factory = new ConnectionFactory { HostName = "118.178.252.28", Port = 5672, UserName = "admin", Password = "Bole12345678", }; // 创建默认内存通道事件源对象,可自定义队列路由key,比如这里是启动项目名称 var rbmqEventSourceStorer = new RabbitMQEventSourceStorer(factory, Assembly.GetExecutingAssembly().GetName().Name, 12000); // 替换默认事件总线存储器 options.ReplaceStorer(serviceProvider => { return rbmqEventSourceStorer; }); }); } } }