Skip to content

Commit

Permalink
Add Broadcast message support to ShardedDaemonProcess (#7451)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Jan 9, 2025
1 parent 80f73bc commit 51ad038
Showing 1 changed file with 16 additions and 5 deletions.
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));
}
}
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

0 comments on commit 51ad038

Please sign in to comment.