Replies: 6 comments 10 replies
-
So one idea would have been to extend the CopmpletableFuture with the callback registration and cancel functions, but that sort of feels ugly. Another one would be, that the PlcSubscriptionResponse, doesn't return a "handle", but a "handler" ... on this handler we could directly register callbacks and end the subscription. |
Beta Was this translation helpful? Give feedback.
-
One variant also would be to always use the tag names and utilize the unsubscription requests with it. Then add callbacks on the connection for tags and those get called not matter if it was a read or subscribe-event response. |
Beta Was this translation helpful? Give feedback.
-
Wouldn't that generally be how it's done right now (At least the first part of your variant)? I just sort of dislike this "each tag separately" concept. Not only do I think it's sort of confusing to write software for, but also is it more challenging to handle the subscriptions. |
Beta Was this translation helpful? Give feedback.
-
So how about leaving most unchanged, but just having one Subscription handle per request and not per tag? |
Beta Was this translation helpful? Give feedback.
-
In most of cases individual tags do not matter, subscription itself is usually a container for updates. Whether protocol handles it as one tag - one subscription, it is implementation detail which can be handled by driver itself. From user perspective, once he submits subscription request in single call cancelling it with one call seems to be consistent. |
Beta Was this translation helpful? Give feedback.
-
So right now I think the process should look like this:
The API function "unsubscribe" would be removed from the connection API. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
since the beginning for me the Subscription API sort of felt sort of odd.
Currently you can create an execute a SubscriptionRequest and add multiple tags to that.
In the response you get one subscription handle per tag.
For each and every tag, you then can register handlers.
There is an alternative path where you can pre-register callbacks for each tag via the addPreRegisteredConsumer method.
While working with subscriptions for only one tag, this might not seem odd. However if you subscribe for multiple tags, things start getting strange, as you have to register handlers for each tag individually.
I would like to propose an alternative approach:
I would like to register only one handler for the entire subscription request. The SubscriptionEvent contains the names of the tags the event contains, so it's still easy to filter.
And while the synchronous requests all return CompletableFutures with the responses and you can register handlers to the completion of these, I would like to return Something similar, for which the user can register the callbacks there and these are then all called for any of the events coming in.
As soon as the user no longer wants to receive events, instead of "unsubscriging" I would like to call "cancel()" or "close()" on the object returned from the subscription request and that takes care of all the unsubscriptions.
Beta Was this translation helpful? Give feedback.
All reactions