Skip to content

Conversation

@marcin-cebo
Copy link
Contributor

@marcin-cebo marcin-cebo commented Oct 9, 2025

The original Message.streamUpdatesOn implementation created excessive resubscribe cycles when called multiple times for messages on the same channel because a SubscriptionSet was created and subscribe() was called for
each execution. FIx is to track whether a subscription already exists for a channel - if
yes, we skip the redundant subscribe() call; if no, we create a Subscription and call subscribe(). When close() method is called on AutoClosable that is returned when calling streamUpdatesOn only when there is last reference to the subscription unsubscribe() method is called.

For each execution of Message.streamUpdatesOn we create

The original Message.streamUpdatesOn implementation created excessive resubscribe cycles when called multiple times for messages on the same channel because a SubscriptionSet was created and subscribe() was called for
  each execution. To fix this, we use global listeners (which receive events from ANY subscription, not just their own) combined with reference counting. We track whether a subscription already exists for a channel - if
  yes, we skip the redundant subscribe() call; if no, we create a SubscriptionSet and call subscribe(). The global listener receives events as long as SOMEONE has subscribed to the channel, allowing multiple streamUpdatesOn
   calls to share a single subscription.
@pubnub-ops-terraform
Copy link
Contributor

pubnub-ops-terraform commented Oct 9, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants