|
@@ -1,5 +1,4 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Data; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Dapper; |
|
|
using Dapper; |
|
|
using DotNetCore.CAP; |
|
|
using DotNetCore.CAP; |
|
@@ -21,7 +20,7 @@ namespace Sample.RabbitMQ.SqlServer.Controllers |
|
|
[Route("~/without/transaction")] |
|
|
[Route("~/without/transaction")] |
|
|
public async Task<IActionResult> WithoutTransaction() |
|
|
public async Task<IActionResult> WithoutTransaction() |
|
|
{ |
|
|
{ |
|
|
await _capBus.PublishAsync("sample.rabbitmq.mysql", new Person() |
|
|
|
|
|
|
|
|
await _capBus.PublishAsync("sample.rabbitmq.sqlserver", new Person() |
|
|
{ |
|
|
{ |
|
|
Id = 123, |
|
|
Id = 123, |
|
|
Name = "Bar" |
|
|
Name = "Bar" |
|
@@ -40,7 +39,11 @@ namespace Sample.RabbitMQ.SqlServer.Controllers |
|
|
//your business code |
|
|
//your business code |
|
|
connection.Execute("insert into test(name) values('test')", transaction: transaction); |
|
|
connection.Execute("insert into test(name) values('test')", transaction: transaction); |
|
|
|
|
|
|
|
|
_capBus.Publish("sample.rabbitmq.mysql", DateTime.Now); |
|
|
|
|
|
|
|
|
_capBus.Publish("sample.rabbitmq.sqlserver", new Person() |
|
|
|
|
|
{ |
|
|
|
|
|
Id = 123, |
|
|
|
|
|
Name = "Bar" |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -54,21 +57,25 @@ namespace Sample.RabbitMQ.SqlServer.Controllers |
|
|
{ |
|
|
{ |
|
|
dbContext.Persons.Add(new Person() { Name = "ef.transaction" }); |
|
|
dbContext.Persons.Add(new Person() { Name = "ef.transaction" }); |
|
|
|
|
|
|
|
|
_capBus.Publish("sample.rabbitmq.mysql", DateTime.Now); |
|
|
|
|
|
|
|
|
_capBus.Publish("sample.rabbitmq.sqlserver", new Person() |
|
|
|
|
|
{ |
|
|
|
|
|
Id = 123, |
|
|
|
|
|
Name = "Bar" |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
return Ok(); |
|
|
return Ok(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[NonAction] |
|
|
[NonAction] |
|
|
[CapSubscribe("sample.rabbitmq.mysql")] |
|
|
|
|
|
public void Subscriber(DateTime p) |
|
|
|
|
|
|
|
|
[CapSubscribe("sample.rabbitmq.sqlserver")] |
|
|
|
|
|
public void Subscriber(Person p) |
|
|
{ |
|
|
{ |
|
|
Console.WriteLine($@"{DateTime.Now} Subscriber invoked, Info: {p}"); |
|
|
Console.WriteLine($@"{DateTime.Now} Subscriber invoked, Info: {p}"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[NonAction] |
|
|
[NonAction] |
|
|
[CapSubscribe("sample.rabbitmq.mysql", Group = "group.test2")] |
|
|
|
|
|
public void Subscriber2(DateTime p, [FromCap]CapHeader header) |
|
|
|
|
|
|
|
|
[CapSubscribe("sample.rabbitmq.sqlserver", Group = "group.test2")] |
|
|
|
|
|
public void Subscriber2(Person p, [FromCap]CapHeader header) |
|
|
{ |
|
|
{ |
|
|
Console.WriteLine($@"{DateTime.Now} Subscriber invoked, Info: {p}"); |
|
|
Console.WriteLine($@"{DateTime.Now} Subscriber invoked, Info: {p}"); |
|
|
} |
|
|
} |
|
|