【发布时间】:2015-04-03 21:30:41
【问题描述】:
我们正在评估我公司的 nservicebus,以重写我们的销售流程。我们将使用 sagas 和 web api。我们在客户端遇到了一个块处理响应。我们使用Handling Responses on the Client Side 进行指导。
从我们的客户端控制器我们有这个代码:
[Route("CreateProduct")]
public ActionResult CreateProduct()
{
ProductCreatedResponse message = null;
var product = new TestProduct { Id = ObjectId.GenerateNewId().ToString() };
var command = new StartProductCommand { ProductId = product.Id, ProductName = "Product1" };
var sync = ServiceBus.Bus.Send("Io.Server." + command.ProductName, command)
.Register(ar =>
{
var localResult = (CompletionResult)ar.AsyncState;
message = (ProductCreatedResponse)localResult.Messages[0];
ViewBag.ResponseText = message.Status;
}, null);
sync.AsyncWaitHandle.WaitOne();
return View("Index");
}
从我们 saga 的处理程序中,我们得到以下代码:
public void Handle(StartProductCommand message)
{
Data.ProductId = message.ProductId;
Data.Status = "Product Created";
var productCreatedResponse = new ProductCreatedResponse { Status = Data.Status };
_bus.Reply(productCreatedResponse );
}
localResult.Messages 为空。我做错了什么?
【问题讨论】:
标签: nservicebus nservicebus-sagas