【发布时间】:2017-04-01 23:15:07
【问题描述】:
我已经构建了一个缓存对象的 Azure Service Fabric 应用/服务。现在使用下面的代码,我在调用服务的控制台窗口中创建了一个客户端。 当在 c.Add 上放置一个断点然后单步执行它时,程序就会退出。不抛出异常,不打印“完成”,程序仅以代码 0 退出。 该服务正在运行并且处于健康状态。我该怎么做才能找出问题所在?
class Program
{
static void Main(string[] args)
{
Test();
}
static async void Test()
{
Uri serviceName = new Uri("fabric:/CacheApp/PreorderCache");
ServicePartitionResolver resolver = new ServicePartitionResolver(() => new System.Fabric.FabricClient());
NetTcpBinding binding = (NetTcpBinding)WcfUtility.CreateTcpClientBinding();
Client c = new Client(new WcfCommunicationClientFactory<IPreorders>(binding, null, resolver), serviceName, 1);
try
{
PreOrder po = await c.Get("50", "11001", OrderNumber = "123456" });
Console.WriteLine("done");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
经过调查,似乎与服务内部使用的事务有关。
服务永远不会过去
await tx.CommitAsync();
这是服务中的错误代码,没什么特别的
await preOrders.GetAsync(tx, d, s, (k, v) => preOrder);
ServiceEventSource.Current.ServiceMessage(this, "after update");
await tx.CommitAsync();
ServiceEventSource.Current.ServiceMessage(this, "after commit");
【问题讨论】:
标签: wcf azure microservices azure-service-fabric