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

[#3549] Improved getOrCreateTopic/Subscription flow for Pub/Sub #3550

Conversation

mattkaem
Copy link
Contributor

Improved getOrCreateTopic/Subscription flow for Pub/Sub messaging infrastructure and changed the subscription expiration to never by adding the default ExpirationPolicy instance to the subscription

@mattkaem mattkaem self-assigned this Sep 25, 2023
@mattkaem mattkaem requested a review from calohmn as a code owner September 25, 2023 13:17
@sophokles73 sophokles73 added C&C Command and Control enhancement labels Sep 26, 2023
@sophokles73 sophokles73 added this to the 2.5.0 milestone Sep 26, 2023
@mattkaem mattkaem force-pushed the improve-pubsub-getOrCreateTopic-and-subscription branch from 431cf59 to f3c0f2b Compare September 27, 2023 13:38
@mattkaem mattkaem requested a review from dejanb as a code owner October 27, 2023 12:22
@mattkaem mattkaem force-pushed the improve-pubsub-getOrCreateTopic-and-subscription branch from 8ebca7c to 0ab4653 Compare October 27, 2023 13:57
@mattkaem mattkaem requested a review from kaniyan as a code owner October 27, 2023 13:57
* A factory to create PubSubBasedAdminClientManagerImpl instances.
*/
@ApplicationScoped
public class PubSubBasedAdminClientManagerFactoryImpl implements PubSubBasedAdminClientManagerFactory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the purpose of having this factory? It doesn't seem to do anything but instantiate the real PubSubBasedAdminClientManager, which could be done directly by the users of this factory, or am I mistaken?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you are right. It doesn't do anything here. I just need it for the Device Communication API in the hono-extras repository, so I just moved it over there.

}

private Future<String> getSubscription(final SubscriptionName subscription, final SubscriptionAdminClient client) {
return vertx.executeBlocking(promise -> promise.tryComplete(client.getSubscription(subscription).getName()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using promise.tryComplete here means that the promise should be completed with the value if it has not yet been completed. I suspect, however, that you intended to complete the promise only in case of the client.getSubscription invocation having succeeded, right?

If so, then you need to wrap the client.getSubscription invocation in a try/catch block and either invoke promise.complete or promise.fail based on the outcome ...

Copy link
Contributor Author

@mattkaem mattkaem Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Somehow it seemed to work like I had it before, but I definitely like your suggestion more, so I implemented it.

Copy link
Contributor

@sophokles73 sophokles73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…ub/Sub messaging infrastructure and changed the subscription expiration to never

Signed-off-by: Matthias Kaemmer <[email protected]>
@mattkaem mattkaem force-pushed the improve-pubsub-getOrCreateTopic-and-subscription branch from b5c0e27 to 0561fa0 Compare November 2, 2023 11:19
@mattkaem mattkaem merged commit 28475fa into eclipse-hono:master Nov 2, 2023
2 checks passed
@mattkaem mattkaem deleted the improve-pubsub-getOrCreateTopic-and-subscription branch November 2, 2023 11:24
@mattkaem mattkaem linked an issue Nov 2, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C&C Command and Control enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Pub/Sub getOrCreateTopic and getOrCreateSubscription flow
2 participants