Add wait-for-subscribers feature#7652
Conversation
…bers-feature # Conflicts: # src/contrib/cluster/Akka.Cluster.Tools/PublishSubscribe/DistributedPubSubMediator.cs
…us/akka.net into Add-wait-for-subscribers-feature
| .ToImmutableDictionary(kv => kv.Key, kv => kv.Value); | ||
| } | ||
| } | ||
| => _registry |
There was a problem hiding this comment.
No logic change, just modernization
| /// <param name="maxBufferedMessagePerTopic">Maximum message buffer size for each topic</param> | ||
| /// <param name="bufferedMessageTimeoutCheckInterval">Buffered message timeout condition check interval</param> | ||
| /// <exception cref="ArgumentException">Thrown if a user tries to use a <see cref="ConsistentHashingRoutingLogic"/> with routingLogic.</exception> | ||
| public DistributedPubSubSettings( |
There was a problem hiding this comment.
New backward compatible .ctor
| /// <param name="maxDeltaElements">The maximum number of delta elements that can be propagated in a single gossip tick.</param> | ||
| /// <param name="sendToDeadLettersWhenNoSubscribers">When a message is published to a topic with no subscribers send it to the dead letters.</param> | ||
| /// <exception cref="ArgumentException">Thrown if a user tries to use a <see cref="ConsistentHashingRoutingLogic"/> with routingLogic.</exception> | ||
| [Obsolete("Use .ctor that supports WaitForSubscribers instead. Since 1.4.42")] |
There was a problem hiding this comment.
A thing we did on #7637 that we should do here:
- Don't even make the CTORs on these settings classes
public. Force users to use thestatic SettingsClass.Createmethod. Eliminates a ton of binary compatibility issues long-term. - Make all of these settings classes into
recordtypes - this eliminates the.WithValueName(method spam.
Maybe we do that across the board in v1.6 - I'm doing it in v1.5 for the TcpSettings type on #7637. I'm fine doing that for DistributedPubSub too.
| /// <param name="maxDeltaElements">The maximum number of delta elements that can be propagated in a single gossip tick.</param> | ||
| /// <param name="sendToDeadLettersWhenNoSubscribers">When a message is published to a topic with no subscribers send it to the dead letters.</param> | ||
| /// <exception cref="ArgumentException">Thrown if a user tries to use a <see cref="ConsistentHashingRoutingLogic"/> with routingLogic.</exception> | ||
| [Obsolete("Use .ctor that supports WaitForSubscribers instead. Since 1.4.42")] |
There was a problem hiding this comment.
Implication of this design change is that users have to call DistributedPubSubSettings.Create(ActorSystem) and then they can manipulate it from there.
| /// <param name="maxDeltaElements">The maximum number of delta elements that can be propagated in a single gossip tick.</param> | ||
| /// <param name="sendToDeadLettersWhenNoSubscribers">When a message is published to a topic with no subscribers send it to the dead letters.</param> | ||
| /// <exception cref="ArgumentException">Thrown if a user tries to use a <see cref="ConsistentHashingRoutingLogic"/> with routingLogic.</exception> | ||
| [Obsolete("Use .ctor that supports WaitForSubscribers instead. Since 1.4.42")] |
There was a problem hiding this comment.
Changing this on v1.5 will probably blow a bunch of stuff up immediately, so we should probably save that for v1.6
Aaronontheweb
left a comment
There was a problem hiding this comment.
Left you a suggestion on the pruning check
Aaronontheweb
left a comment
There was a problem hiding this comment.
Left some more suggestions but I think overall the design looks good - what's the testing plan?
| { | ||
| if (message is PublishWithAck needAck) | ||
| { | ||
| sender.Tell(new PublishFailed(needAck, PublishFailReason.Timeout)); |
There was a problem hiding this comment.
Do we want to do an early return here and skip logging the dead letter or do we want to do both? The way we have it does both and I actually think that's ok - since the DeadLetter monitoring will usually get universal attention.
There was a problem hiding this comment.
I don't think its wise to change old behavior
| } | ||
|
|
||
| private void PublishToEachGroup(string path, Publish publish) | ||
| private void PublishToEachGroup(string path, IWrappedMessage publish) |
There was a problem hiding this comment.
IMHO, do a common interface for both of the Publish message types and handle that instead.
There was a problem hiding this comment.
This can't be done because PublishMessage is also used to send SendAll
Fixes #7627
DistributedPubSub wait-for-subscriber feature flag
HOCON settings added
Settings added to DistributedPubSubSettings
Buffer
PublishWithAckmessage and able to deliver it immediately, it will send back aPublishSucceededmessage back to the original sender as a signal.PublishWithAckmessage, it will store the message as aBufferedMessageinside the buffer.Buffer timeout
PublishWithAckmessage contains the timeout value for each messagestimeout-check-intervaltime, the mediator will scan through all of the buffered message to check and see if it has been sitting in the buffer for more than timeout period.PublishFailuremessage will also be sent to the original sender to signal publish failures.Buffer delivery
NewBucketKeysAddedmessage to itself.NewBucketKeysAddedmessage is received, the mediator checks the buffer and re-send all waiting messages that matches the keys to itself.PublishSucceededmessage to the original sender as a signal.Buffer overflow
When a new message is inserted and the topic buffer count exceeds
buffered-messages.max-per-topic, the mediator will discard the oldest message in the buffer and send aPublishFailedto the original sender of that message.Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):