@@ -35,9 +35,16 @@ namespace Sample.RabbitMQ.SqlServer.Controllers | |||||
[Route("~/publish")] | [Route("~/publish")] | ||||
public IActionResult PublishMessage() | public IActionResult PublishMessage() | ||||
{ | { | ||||
_capBus.Publish("sample.rabbitmq.mysql22222", DateTime.Now); | |||||
// _capBus.Publish("sample.rabbitmq.mysql33333", person); | |||||
_capBus.Publish("sample.rabbitmq.sqlserver.order.check", DateTime.Now); | |||||
//var person = new Person | |||||
//{ | |||||
// Name = "杨晓东", | |||||
// Age = 11, | |||||
// Id = 23 | |||||
//}; | |||||
//_capBus.Publish("sample.rabbitmq.mysql33333", person); | |||||
return Ok(); | return Ok(); | ||||
} | } | ||||
@@ -24,7 +24,7 @@ namespace Sample.RabbitMQ.SqlServer | |||||
//host.Run(); | //host.Run(); | ||||
public static void Main(string[] args) | public static void Main(string[] args) | ||||
{ | |||||
{ | |||||
BuildWebHost(args).Run(); | BuildWebHost(args).Run(); | ||||
} | } | ||||
@@ -8,9 +8,10 @@ namespace Sample.RabbitMQ.SqlServer.Services.Impl | |||||
{ | { | ||||
public class OrderService : IOrderService, ICapSubscribe | public class OrderService : IOrderService, ICapSubscribe | ||||
{ | { | ||||
[CapSubscribe("sample.rabbitmq.sqlserver.order.check")] | |||||
public void Check() | public void Check() | ||||
{ | { | ||||
throw new NotImplementedException(); | |||||
Console.WriteLine("out"); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -13,7 +13,7 @@ namespace Sample.RabbitMQ.SqlServer | |||||
{ | { | ||||
services.AddDbContext<AppDbContext>(); | services.AddDbContext<AppDbContext>(); | ||||
services.AddTransient<IOrderService, OrderService>(); | |||||
services.AddScoped<IOrderService, OrderService>(); | |||||
services.AddTransient<ICmsService, CmsService>(); | services.AddTransient<ICmsService, CmsService>(); | ||||
services.AddCap(x => | services.AddCap(x => | ||||