Closed alexanderankin closed 1 year ago
The attached is the result of my simplification of a part of the hivemq-hq-issued sample code. its not perfect but it does demonstrate what i am talking about:
Hi @alexanderankin Thank you for your detailed description.
I think it makes sense to just use reactor
You can already use reactor as the API, see here: https://hivemq.github.io/hivemq-mqtt-client/docs/installation/#optional-features
I can give an example. one of the subscribe apis returns a FlowableWithSingle<F, S> where S is the single type and F is the Flowable type.
There is an explicit reason why the API was designed like that. We can not just split into a separate Flowable and Single. Subscribing to the Single would create the subscription on the MQTT level and messages matching this subscription will immediately be delivered to the client. When then subscribing to the Flowable, some messages might be missed. Basically this creates a lot of cases resulting in this race condition.
deprecated RxJava2
The next version of the client will upgrade to RxJava 3 (and of course keep the already available reactor API). The next version will come once we get to it which might actually happen soon.
Since there haven't been any updates in 6 months I will close out this issue. If anything remains, please feel free to re-open or file another issue. Thanks @alexanderankin for opening this discussion!
Problem or use case
the api is very difficult to abstract, and requires coupling with the deprecated RxJava2 and its replacement, the reactivesreams spec.
Preferred solution or suggestions
I think it makes sense to just use reactor, but perhaps a thoughtful investigation into the particular use cases can add alternative methods which return datastructures with a bit of overhead but a simplified API that is not tied to a particular implementation (but just the concepts of Single/Flowable, Mono/Flux, etc)
I would just like to discuss the degree of possibility of such an addition in this project, i think the implementation details can be determined once the motivation is established, to simplify the API.
I can give an example. one of the subscribe apis returns a
FlowableWithSingle<F, S>
whereS
is the single type andF
is the Flowable type. This could have instead been addressed in the business logic rather than the async abstraction layer, like so:This alone will go a long way to letting users avoid the fluent api, which anyone using this for work will need to do as they will need to configure the client using static properties from a secrets manager.