Skip to content

Commit 51ad038

Browse files
authored
Add Broadcast message support to ShardedDaemonProcess (#7451)
1 parent 80f73bc commit 51ad038

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/contrib/cluster/Akka.Cluster.Sharding/ShardedDaemonProcess.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,23 @@ public DaemonMessageRouter(string[] entityIds, IActorRef shardingRef)
112112

113113
protected override void OnReceive(object message)
114114
{
115-
var nextId = _entityIds[_index % _entityIds.Length];
115+
if (message is Broadcast broadcast)
116+
{
117+
var unwrapped = broadcast.Message;
118+
foreach (var entityId in _entityIds)
119+
{
120+
_shardingRef.Forward(new ShardingEnvelope(entityId, unwrapped));
121+
}
122+
}
123+
else
124+
{
125+
var nextId = _entityIds[_index % _entityIds.Length];
116126

117-
// have to remember to always allow the sharding envelope to be forwarded
118-
_shardingRef.Forward(new ShardingEnvelope(nextId, message));
119-
if (_index == int.MaxValue) _index = 0;
120-
else _index++;
127+
// have to remember to always allow the sharding envelope to be forwarded
128+
_shardingRef.Forward(new ShardingEnvelope(nextId, message));
129+
if (_index == int.MaxValue) _index = 0;
130+
else _index++;
131+
}
121132
}
122133
}
123134

0 commit comments

Comments
 (0)