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

[PORT #6209] Make sure that DeadLetters published by DistributedPubSubMediator contain full context of topic #6212

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,19 @@ public DistributedPubSubMediator(DistributedPubSubSettings settings)
new Router(_settings.RoutingLogic, routees.ToArray()).Route(
Internal.Utils.WrapIfNeeded(send.Message), Sender);
else
IgnoreOrSendToDeadLetters(send.Message);
IgnoreOrSendToDeadLetters(send);
});
Receive<SendToAll>(sendToAll =>
{
PublishMessage(sendToAll.Path, sendToAll.Message, sendToAll.ExcludeSelf);
PublishMessage(sendToAll.Path, sendToAll, sendToAll.ExcludeSelf);
});
Receive<Publish>(publish =>
{
string path = Internal.Utils.MakeKey(Self.Path / Internal.Utils.EncodeName(publish.Topic));
if (publish.SendOneMessageToEachGroup)
PublishToEachGroup(path, publish.Message);
PublishToEachGroup(path, publish);
else
PublishMessage(path, publish.Message);
PublishMessage(path, publish);
});
Receive<Put>(put =>
{
Expand Down Expand Up @@ -500,7 +500,7 @@ private void IgnoreOrSendToDeadLetters(object message)
Context.System.DeadLetters.Tell(new DeadLetter(message, Sender, Context.Self));
}

private void PublishMessage(string path, object message, bool allButSelf = false)
private void PublishMessage(string path, IWrappedMessage publish, bool allButSelf = false)
{
IEnumerable<IActorRef> Refs()
{
Expand All @@ -521,24 +521,24 @@ IEnumerable<IActorRef> Refs()
foreach (var r in Refs())
{
if (r == null) continue;
r.Forward(message);
r.Forward(publish.Message);
counter++;
}

if (counter == 0) IgnoreOrSendToDeadLetters(message);
if (counter == 0) IgnoreOrSendToDeadLetters(publish);
}

private void PublishToEachGroup(string path, object message)
private void PublishToEachGroup(string path, Publish publish)
{
var prefix = path + "/";
var lastKey = path + "0"; // '0' is the next char of '/'

var groups = ExtractGroups(prefix, lastKey).GroupBy(kv => kv.Key).ToList();
var wrappedMessage = new SendToOneSubscriber(message);
var wrappedMessage = new SendToOneSubscriber(publish.Message);

if (groups.Count == 0)
{
IgnoreOrSendToDeadLetters(message);
IgnoreOrSendToDeadLetters(publish);
}
else
{
Expand Down