static void rabbitMQSubscribe() { var appSettings = GetAppSettings(); var mqService = new RabbitMQService( appSettings.RabbitMQ.HostName, appSettings.RabbitMQ.Port, appSettings.RabbitMQ.UserName, appSettings.RabbitMQ.Password); //订阅用户注册消息 mqService.Subscribe <RegisterMemberEvent>( "RegisterMemberEvent", "RegisterMemberAddAccount", _ => { var accountBusiness = new AccountBusiness(); accountBusiness.dbContext = new MSSQLDbContext("MSDbConnection"); return(accountBusiness.AddAccount(_.MemberId)); }); //订阅支付成功消息--订单处理 mqService.Subscribe <PaymentPaidEvent>( "PaymentPaidEvent", "PaymentPaidOrder", _ => { if (_.Type != Example.IBusiness.Model.PaymentType.Order) { return(true); } var orderBusiness = new OrderBusiness(); orderBusiness.dbContext = new MSSQLDbContext("MSDbConnection"); return(orderBusiness.Notify(_.Identity_Id, _.PaymentId)); }); //订阅支付成功消息--充值处理 mqService.Subscribe <PaymentPaidEvent>( "PaymentPaidEvent", "PaymentPaidRecharge", _ => { if (_.Type != Example.IBusiness.Model.PaymentType.Recharge) { return(true); } //var rechargeBusiness = new RechargeBusiness(); //rechargeBusiness.dbContext = new MSSQLDbContext("MSDbConnection"); return(true); }); }
private void btnStartService_Click(object sender, EventArgs e) { _rabbitMQService.Subscribe("routingKey_B", RabbitMQCallback); _rabbitMQService.Start(); MessageBox.Show("RabbitMQService 已启动。"); }
public bool Start() { _rabbitMqProxy.Subscribe <MessageModel>(msg => { var json = SerializerJson.SerializeObject(msg); Console.WriteLine(json); }); return(true); }
private CommandExecuterService() { _rabbitMQService.Subscribe(MessageHandle); }