-
Notifications
You must be signed in to change notification settings - Fork 1
[broker-30] Implement delivering retained messages #54
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
Open
crazyrokr
wants to merge
46
commits into
develop
Choose a base branch
from
feature-broker-30
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
26129f5
[broker-30] Implement delivering retained messages
crazyrokr c6ada4d
[broker-30] Rewrite retained messages collecting
crazyrokr 94b32db
Merge branch 'develop' into feature-broker-30
crazyrokr 01bac5b
[broker-30] Cleanup code after merge
crazyrokr c903510
[broker-30] Fix corner cases in retained messages
crazyrokr e1f5c2a
[broker-30] Handle SubscribeRetainHandling
crazyrokr a8829ac
Merge branch 'develop' into feature-broker-30
crazyrokr a1b87dd
[broker-30] Fix build
crazyrokr fd848eb
Merge branch 'develop' into feature-broker-30
crazyrokr be8070b
[broker-30] SubscriberNode refactoring
crazyrokr 0c219dd
[broker-30] Revert wrong access level modifier
crazyrokr 62900ca
[broker-30] Avoid tree branch locking
crazyrokr dc1d443
Merge branch 'develop' into feature-broker-30
crazyrokr 7314ed1
[broker-30] Introduce AbstractTrieNode
crazyrokr 901e865
[broker-30] Remove redundant code from SubscriberNode
crazyrokr cc91db2
[broker-30] Revert redundant changes
crazyrokr 42af014
[broker-30] Improve AbstractTrieNode
crazyrokr b1aa456
[broker-30] Implement retainAsPublished support
crazyrokr f2f2f67
[broker-30] Update debug message
crazyrokr bf837eb
[broker-30] Small refactoring
crazyrokr cc08339
[broker-30] Avoid double message retaining
crazyrokr bacefb7
[broker-30] Add more tests
crazyrokr c2ac2ad
Merge branch 'develop' into feature-broker-30
crazyrokr 1d37242
[broker-30] Fix tests
crazyrokr c3ab5c5
[broker-30] Fix retainAsPublished logic
crazyrokr b829090
[broker-30] Add tests
crazyrokr 26f45dc
[broker-30] Introduce RetainMessageService
crazyrokr 6c16962
[broker-30] Rework retainAsPublished handling
crazyrokr 12f8069
Merge branch 'develop' into feature-broker-30
crazyrokr 31ff664
[broker-30] Fix formatting
crazyrokr 8191bc8
[broker-30] Improve RetainedMessageTreeTest
crazyrokr c7c72d3
[broker-30] Improve code readability
crazyrokr 8a23e97
[broker-30] Extract creation of SingleSubscriber to SubscriptionService
crazyrokr 57eeb77
[broker-30] Revert unnecessary changes
crazyrokr 28e73a5
[broker-30] Fix QoS comparison
crazyrokr 2fb16a5
Merge branch 'develop' into feature-broker-30
crazyrokr f4a6727
[broker-30] Update tests
crazyrokr 751624f
[broker-30] Introduce setRetainedMessage and clearRetainedMessage
crazyrokr 649f57e
[broker-30] Move publish.retained() check to caller
crazyrokr b4e1232
[broker-30] Extract isRetainHandlingSatisfied() method
crazyrokr 1f3d50a
[broker-30] Revert formatting
crazyrokr 588aae4
[broker-30] Revert SubscriberNode
crazyrokr 07ce54d
[broker-30] Reduce memory allocation of RetainedMessageNode
crazyrokr 3163a8a
Merge branch 'develop' into feature-broker-30
crazyrokr 17359d3
[broker-30] Refactoring
crazyrokr ffb1c83
[broker-30] Update tests
crazyrokr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
core-service/src/main/java/javasabr/mqtt/service/RetainMessageService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package javasabr.mqtt.service; | ||
|
|
||
| import javasabr.mqtt.model.publishing.Publish; | ||
| import javasabr.mqtt.model.subscriber.SingleSubscriber; | ||
| import javasabr.mqtt.model.subscriber.Subscriber; | ||
| import javasabr.mqtt.model.subscription.Subscription; | ||
| import javasabr.mqtt.service.publish.handler.PublishHandlingResult; | ||
| import javasabr.rlib.collections.array.Array; | ||
|
|
||
| public interface RetainMessageService { | ||
|
|
||
| void retainMessage(Publish publish); | ||
|
|
||
| void deliverRetainedMessages(Subscriber subscriber); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
core-service/src/main/java/javasabr/mqtt/service/impl/DefaultRetainMessageService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package javasabr.mqtt.service.impl; | ||
|
|
||
| import javasabr.mqtt.model.publishing.Publish; | ||
| import javasabr.mqtt.model.subscriber.SingleSubscriber; | ||
| import javasabr.mqtt.model.subscriber.Subscriber; | ||
| import javasabr.mqtt.model.subscription.Subscription; | ||
| import javasabr.mqtt.model.topic.tree.ConcurrentRetainedMessageTree; | ||
| import javasabr.mqtt.service.PublishDeliveringService; | ||
| import javasabr.mqtt.service.RetainMessageService; | ||
| import javasabr.mqtt.service.publish.handler.PublishHandlingResult; | ||
| import javasabr.rlib.collections.array.Array; | ||
| import javasabr.rlib.collections.array.MutableArray; | ||
| import lombok.AccessLevel; | ||
| import lombok.experimental.FieldDefaults; | ||
|
|
||
| @FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true) | ||
| public class DefaultRetainMessageService implements RetainMessageService { | ||
|
|
||
| PublishDeliveringService publishDeliveringService; | ||
| ConcurrentRetainedMessageTree retainedMessageTree; | ||
|
|
||
| public DefaultRetainMessageService(PublishDeliveringService publishDeliveringService) { | ||
| this.publishDeliveringService = publishDeliveringService; | ||
| this.retainedMessageTree = new ConcurrentRetainedMessageTree(); | ||
| } | ||
|
|
||
| @Override | ||
| public void retainMessage(Publish publish) { | ||
| retainedMessageTree.retainMessage(publish); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public void deliverRetainedMessages(Subscriber subscriber) { | ||
| SingleSubscriber singleSubscriber = subscriber.resolveSingle(); | ||
| Subscription subscription = singleSubscriber.subscription(); | ||
| boolean retainAsPublished = subscription.retainAsPublished(); | ||
| Array<Publish> retainedMessages = retainedMessageTree.getRetainedMessage(subscription.topicFilter()); | ||
| MutableArray<PublishHandlingResult> result = MutableArray.ofType(PublishHandlingResult.class); | ||
| for (Publish message : retainedMessages) { | ||
| if (!retainAsPublished) { | ||
| message = message.withoutRetain(); | ||
| } | ||
| publishDeliveringService.startDelivering(message, singleSubscriber); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.