幼教资源网网站开发策划书,制作网页时我们应当如何规避侵权风险,微信小程序制作公司,盐城做网站的价格消息发布器#xff1a;Ray是基于Event Sourcing设计的ES/Actor框架#xff0c;ESGrain状态#xff08;State#xff09;的修改、ESGrain之间的通信默认使用RabbitMQ通信。消息的发布器主要是RabbitPubESGrain。RabbitPub特性RabbitPub特性是RabbitMQ消息发布器。RabbitSub特… 消息发布器Ray是基于Event Sourcing设计的ES/Actor框架ESGrain状态State的修改、ESGrain之间的通信默认使用RabbitMQ通信。消息的发布器主要是RabbitPubESGrain。RabbitPub特性RabbitPub特性是RabbitMQ消息发布器。RabbitSub特性用到的构造函数如下public RabbitPubAttribute(string exchange null, string queue null, int queueCount 1){this.Exchange exchange;this.Queue queue;this.QueueCount queueCount;}exchangeRabbitMQ中的exchange名称。queueRabbitMQ中的queue名称。queueCount消息队列数。用于消息的负载均衡。使用为对应的Actor添加RabbitMQ.RabbitPub特性继承MongoESGrain或SqlGrain在方法中使用实例化事件并调用RaiseEvent发布事件。示例[RabbitMQ.RabbitPub(Account, account)]
public sealed class Account : MongoESGrainString, AccountState, IGrains.MessageInfo, IAccount{……}
public Task Transfer(string toAccountId, decimal amount){var evt new AmountTransferEvent(toAccountId, amount, this.State.Balance - amount);return RaiseEvent(evt).AsTask();}RabbitPub可以单独使用用于发布消息。消息存储器消息的存储器用于持久化ESGrain的Event事件与State快照数据需要的时候进行重放。Ray默认使用MongoDB存储事件和快照。使用 为对应的Actor添加MongoStorage特性。public MongoStorageAttribute(string eventDatabase, string collection, bool sharding false, int shardingDays 90)
{this.EventDataBase eventDatabase;this.EventCollection collection Event;this.SnapshotCollection collection State;this.sharding sharding;this.shardingDays shardingDays;CreateCollectionIndex();//创建分表索引CreateStateIndex();//创建快照索引
}eventDatabase:事件的Database名称。collection事件的collection名称。sharding是否需要分表默认值false。shardingDays分表时间间隔默认值90天。示例[RabbitMQ.RabbitPub(Account, account)]
[MongoStorage(Test, Account)]//事件存储
public sealed class Account : MongoESGrainString, AccountState, IGrains.MessageInfo, IAccount
{
……
}shardingDays分表时间间隔有个起始点开始时间在MongoConfig中定义。具体使用参见Example.Ray.Host中StartSilo()方法。相关文章Actor-ES框架RayActor-ES框架Ray--事件Event编写说明Ray框架QAActor-ES框架Ray-Handler之CoreHandler编写Actor-ES框架Ray-Handler之ToReadHandler编写Actor-ES框架Actor编写-ESGrain与ESRepGrain原文地址:http://www.cnblogs.com/CharlesZHENG/p/8438051.html.NET社区新闻深度好文欢迎访问公众号文章汇总 http://www.csharpkit.com