Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the message publisher and message store in the Actor-ES framework?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the Actor-ES framework of the message publisher and message memory is how, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Message publisher:

Ray is an ES/Actor framework designed based on Event Sourcing. The modification of ESGrain state (State) and the communication between ESGrain use RabbitMQ communication by default. The main publisher of the message is RabbitPub+ESGrain.

RabbitPub characteristics

The RabbitPub feature is the RabbitMQ message publisher.

The constructors used for the RabbitSub feature are as follows:

Public RabbitPubAttribute (string exchange = null, string queue = null, int queueCount = 1) {this.Exchange = exchange; this.Queue = queue; this.QueueCount = queueCount;}

The exchange name in exchange:RabbitMQ.

The queue name in queue:RabbitMQ.

QueueCount: number of message queues. Load balancing for messages.

Use:

Add a RabbitMQ.RabbitPub feature to the corresponding Actor

Inherit MongoESGrain or SqlGrain

Use the instantiated event in the method and call RaiseEvent to publish the event.

Example:

[RabbitMQ.RabbitPub ("Account", "account")] public sealed class Account: MongoESGrain, IAccount {. } public Task Transfer (string toAccountId, decimal amount) {var evt = new AmountTransferEvent (toAccountId, amount, this.State.Balance-amount); return RaiseEvent (evt). AsTask ();}

RabbitPub can be used alone to publish messages.

Message memory:

The memory of the message is used to persist ESGrain's Event events and State snapshot data and replay them when needed. Ray defaults to using MongoDB to store events and snapshots.

Use: to add a MongoStorage feature to the corresponding Actor.

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 (); / / create sub-table index CreateStateIndex (); / / create snapshot index}

EventDatabase: the Database name of the event.

Collection: the collection name of the event.

Sharding: whether a sub-table is required. The default is false.

ShardingDays: sub-table interval. Default is 90 days.

Example:

[RabbitMQ.RabbitPub ("Account", "account")] [MongoStorage ("Test", "Account")] / / event storage public sealed class Account: MongoESGrain, IAccount {. }

The shardingDays sub-table interval has a starting point, and the start time is defined in MongoConfig. For specific use, see the StartSilo () method in Example.Ray.Host.

On the Actor-ES framework of the message publisher and message memory is shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report