I want multiple subscriptions on same event or same property, is that possible?
Not from the same thing, this is a huge limitation on the platform that R&D introduced silently on 6.5, still I don't find the reason ( we had long chats with R&D about this).
We had to build our own DataChange event system in order to overpass that huge limitation
Even if we build our own event then also it wouldn't allow us to create multiple subscriptions on that same event?
Any update on this? Were any of the discusstion posts helpful? If so, could you click on the "correct answer" button and let us know?
from the same thing you can add multiple subscriptions for:
-same event with different properties or,
-same property but events should be different
but if you want to add multiple subscriptions for same events with same property in same thing, I don't think there is need to write multiple subscriptions in this case. you can write your code in single subscription with different conditions according to your need.
Hi Priyanshi Saxena,
Multiple subscription to the same Thing property is not possible currently.
As a workaround you can write different services for different subscription and then call all the services in the single subscription code.
Hope it helps.
If you write different services for different subscription and then call all the services in the single subscription code, that's not really flexible when you have multiple ThingShapes interacting, and makes the solution not really flexible.
That's the real reason on having multiple subscriptions to the same event from the same thing, making a really decoupled system, what you are proposing it's a coupled system which using in development it's a big problem for complex and flexible systems.
Thank you for your valuable input.
Could you please elaborate more on this. I would like to understand the pros of having multiple subscription to same Thing in a complex system.
As per my understanding having multiple subscription to same Thing had some cons. For example we didn't had control over which subscription will run first. So, if two or more subscription code is updating the same property we cannot confirm the final result. Somewhat like race condition in Threads.
We can start a long discussion on this... We had a long discussion a while back when R&D decided to pull off this feature.
Your first point "we didn't had control over which subscription will run first" --> Neither you have control when Event will be Fired/Executed as it may be executed on different threads, your code should support parallelism, we are on a concurrent system, then this problem you are saying it's always there.
About having two or more subscription code updating the same property --> Same as before, this may happen always, not becouse of the subscriptions on the same event from the same thing, you can have timers, other subscriptions which writes to the same property, and so and so.
About the pros:
Hi Charles, absolutely agree!!
The race condition is hopefully not the reason for switching this off. Every MQTT Server does allow multiple subscriptions on keys and fire them in a non predictive way to the subscribers. No issue. there. You just have to be aware.
Secondly there are several other conditions like timer events that can also cause race conditions on property changes. You comments regarding the discussion with R&D makes me really scary.
Nice to meet you, yes you can be scared about this, the talk with R&D was tough (back in July 2015), still now I can't believe their answer, and as time passes we will see more and more complaining customers on this ( as IoT solutions get more complex as are our one ).
Hi Carles Coll Good Morning !
Seeing your experience with this particular issue ,Though I am new to Thingworx funcationality , I have a point to make :
In this current IoT age leading to increased complexity , we might have to implement multiple subscription (I mean other places where this can be achieved ) sooner than we expect and when we have such huge use of concurrency , thread safe mechanism and data structure , this should not be an issue at all. And we can not say to customers that our applications is not fully thread safe , as it should be.
The Pros and cons of have multi threaded environment is always there , however we do prefer use of thread safe mechanism where the need is.
I agree that there are certain disadvantages like
However at same time , we also have advantages of using multi threaded environment like
I may be going little out of context , however I believe there is several reasons for us to provide thread safe data structures in spite , it will add to complexity and development needs to think and work in direction sooner the better .
Please let me know if I am in wrong direction on this topic .
But this limitation doesn't maters on a Thread Safe data structure, this limitation in fact increases complexity --> On our case we had to build our own multi-subscription system in order to reach customer requirements --> It increased a lot our solution complexity.
okay , I understand now . So would be solution for this ? Custom solution by customer or by PTC to get this resolved ?
As you correctly pointed out that there would be increasing demands of such functionality , do we have any road map to address this issue in near future ? Or we would suggest to avoid such designs ?
R&D removed this feature silently on 6.5, previous to 6.5 you where able to have multiple subscriptions to the same thing/event from the same thing. We discovered becouse everything failed on 6.5, and we had to build our own solution.
Roadmap, as you see, they removed it, we will have to push them to get it back on the product, how? I don't know.
It's impossible to avoid such designs, the problem here it's the limitation not that complex uncoupled designs, coupled designs are a big deal/problem.
"On our case we had to build our own multi-subscription system in order to reach customer requirements"
Did you guys ended up building this as an outside component (using things like MQTT server) or did you build an extension within Thingworx using SDK ?
Not as an outside component, we have a Generic Thing Shape plugged to all the things which subscribes to AnyDataChangeEvent, and it handles triggering a fake DataChange event for each property based on a Infotable that keeps track of DataChange subscriptions for properties, adding lost multi-subscription feature, and also some nice features like prioritized and optionally delayed DataChange event execution.
Starting from 8.4, it should be possible to create multiple (named) subscriptions for a single event.
That sounds promising, what are named subscriptions? it will apply to all types of subscriptions Static/Dynamic?
Static subscriptions have a name in 8.4 (to be able to differentiate multiple subscriptions on the same event).
It is also possible to create multiple dynamic Subscriptions on the same event (dynamic one are not named).
All this is pending official 8.4 release.
hi what is the official release date for 8.4 ? and where can I find that info on support site ?
There is no foretasted date yet for ThingWorx 8.4 in the Product Calendar
This is also an issue in the ThingWorx Utilities because the FileTransferEvent is already "catched" by a subscription implemented in TW.RSM.Template.AssetWithTunnelsAndFileTransfer. Therefore no inheriting ThingTemplate can implement a subscription to the FileTransferEvent.
Unfortunately this issue is still not solved, see Thing Subscriptions:
"Duplicate subscriptions are not supported in ThingWorx version 6.5.1 and later. For example, if a thing template has a subscription to the AnyDataChange event, you cannot add a AnyDataChange event to the thing that uses the thing template."
For the mentioned FileTransferEvent issue there seem to be an improvement in TWX Utilities 7.3.0, see Capturing File Transfer History.