static void Main(string[] args) { var bootstrapper = AbpBootstrapper.Create <TestRemoteEventBusModule>(); bootstrapper.Initialize(); var remoteEventBus = bootstrapper.IocManager.Resolve <IRemoteEventBus>(); Task.Factory.StartNew(() => { while (true) { const string type = "Type_Test"; const string topic = "Topic_Test"; var eventDate = new RemoteEventData(type) { Data = { ["playload"] = DateTime.Now } }; remoteEventBus.Publish(topic, eventDate); Task.Delay(1000).Wait(); } }); Console.WriteLine("任意键退出"); Console.ReadKey(); }
static void Main(string[] args) { var bootstrapper = AbpBootstrapper.Create <RabbitMQTestModule>(); bootstrapper.IocManager.IocContainer.AddFacility <LoggingFacility>(f => f.UseAbpLog4Net().WithConfig("log4net.config")); bootstrapper.Initialize(); var remoteEventBus = bootstrapper.IocManager.Resolve <IRemoteEventBus>(); Task.Factory.StartNew(() => { while (true) { const string type = "Type_Test"; const string topic = "Topic_Test"; var eventDate = new RemoteEventData(type) { Data = { ["playload"] = DateTime.Now } }; remoteEventBus.Publish(topic, eventDate); Task.Delay(1000).Wait(); } }); Console.WriteLine("Any key exit"); Console.ReadKey(); }
public string Get() { var EventData = new RemoteEventData("Type_Test") { Data = { ["playload"] = DateTime.Now } }; //发布事件 _remoteEventBus.Publish("Topic_Test", eventData: EventData); return("OK"); }
/// <summary> /// 测试分布式事件总线 /// </summary> public void TestRemoteEventBus() { EventData = new RemoteEventData("Type_Test") { Data = { ["playload"] = DateTime.Now } }; //事务执行成功时发送数据,否则不发送 CurrentUnitOfWork.Completed += CurrentUnitOfWork_Completed; //测试出现异常的情况, //throw new Exception(); }