企业应用中微服务架构的应用
1. 实现 LogStore 微服务的通信接收端
要实现 LogStore 微服务,需添加对 Interaction 库的引用,它会自动创建对远程库和 IdempotencyTools 项目的引用。LogStore 类要实现 ILogStore 接口,以下是相关代码:
internal sealed class LogStore : StatefulService, ILogStore
{
private IReliableQueue<IdempotentMessage<PurchaseInfo>> LogQueue = null;
public async Task<bool> LogPurchase(IdempotentMessage<PurchaseInfo> idempotentMessage)
{
if (LogQueue == null) return false;
using (ITransaction tx = this.StateManager.CreateTransaction())
{
await LogQueue.EnqueueAsync(tx, idempotentMessage);
await tx.CommitAsync();
return true;
}
}
}
当服务从远程运行时接收到 LogPurchase 调用,会将消息放入
超级会员免费看
订阅专栏 解锁全文
37

被折叠的 条评论
为什么被折叠?



