Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Broadcast message support to ShardedDaemonProcess #7451

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,23 @@ public DaemonMessageRouter(string[] entityIds, IActorRef shardingRef)

protected override void OnReceive(object message)
{
var nextId = _entityIds[_index % _entityIds.Length];
if (message is Broadcast broadcast)
{
var unwrapped = broadcast.Message;
foreach (var entityId in _entityIds)
{
_shardingRef.Forward(new ShardingEnvelope(entityId, unwrapped));
}
}
Comment on lines +115 to +122
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Special case, when message is wrapped inside the Broadcast envelope, send the payload to all worker entities.

else
{
var nextId = _entityIds[_index % _entityIds.Length];

// have to remember to always allow the sharding envelope to be forwarded
_shardingRef.Forward(new ShardingEnvelope(nextId, message));
if (_index == int.MaxValue) _index = 0;
else _index++;
// have to remember to always allow the sharding envelope to be forwarded
_shardingRef.Forward(new ShardingEnvelope(nextId, message));
if (_index == int.MaxValue) _index = 0;
else _index++;
}
}
}

Expand Down
Loading