Skip to content
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