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

DistributedPubSub: put messages without route into the dead letters #19009

Closed
maqdev opened this issue Nov 25, 2015 · 3 comments
Closed

DistributedPubSub: put messages without route into the dead letters #19009

maqdev opened this issue Nov 25, 2015 · 3 comments
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted help wanted Issues that the core team will likely not have time to work on t:cluster-tools
Milestone

Comments

@maqdev
Copy link

maqdev commented Nov 25, 2015

Currently if you publish message using publishToEachGroup and there is no subscribers on this topic that message is just lost. It would be much better to be able to handle this situation and put the message into the dead letter for the further debugging and processing.

To achieve this result for myself I created a new class that inherits DistributedPubSubMediator and implemented it like this:

override def publishToEachGroup(path: String, msg: Any): Unit = {
    val prefix = path + '/'
    val lastKey = path + '0' // '0' is the next char of '/'
    val hasAtLeastOneReceiver = registry.exists(_._2.content.range(prefix, lastKey).nonEmpty)
    if (hasAtLeastOneReceiver) {
      super.publishToEachGroup(path, msg)
    } else {
      context.system.deadLetters ! DeadLetter(msg, sender(), context.self)
}

Also there is other sending methods that have to be modified like Send, SendToAll, Publish, etc.

@rkuhn rkuhn added 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted help wanted Issues that the core team will likely not have time to work on t:cluster-tools labels Dec 16, 2015
@rkuhn rkuhn added this to the 2.4.x milestone Dec 16, 2015
@rkuhn
Copy link
Contributor

rkuhn commented Dec 16, 2015

one remark: “further processing” sounds scary—you do know that deadLetters are not reliable, right?

@maqdev
Copy link
Author

maqdev commented Dec 16, 2015

Yes, I do :-)

@rkuhn
Copy link
Contributor

rkuhn commented Dec 16, 2015

good :-)

@rkuhn rkuhn removed the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label Mar 9, 2016
@patriknw patriknw added the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label Mar 9, 2016
@johanandren johanandren modified the milestones: 2.4.5, 2.4.x May 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted help wanted Issues that the core team will likely not have time to work on t:cluster-tools
Projects
None yet
Development

No branches or pull requests

4 participants