Skip to main content
1-Visitor
September 21, 2016
Question

Can we have multiple subscriptions on the same property or same "AnyDataChange" event.

  • September 21, 2016
  • 7 replies
  • 10653 views

I want multiple subscriptions on same event or same property, is that possible?

7 replies

1-Visitor
September 21, 2016

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

psaxena1-VisitorAuthor
1-Visitor
September 21, 2016

Even if we build our own event then also it wouldn't allow us to create multiple subscriptions on that same event?

1-Visitor
March 3, 2017

Priyanshi,

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?

1-Visitor
September 21, 2016

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.

Thanks,
Meenakshi

5-Regular Member
September 21, 2016

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.

Thanks,

Ankit Gupta

1-Visitor
September 21, 2016

Hi Ankit/Meenakshi,

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.

Best Regards,

Carles.

5-Regular Member
September 21, 2016

Hi Carles,

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.

Thanks,

Ankit Gupta

1-Visitor
September 21, 2016

Hi Ankit,

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:

  • I can write Services which subscribes to properties dynamically on demand, this subscriptions will be done on runtime and depending on Thing Instance, and I can have subscriptions generated from different ThingShapes becouse the event maters to some of them.
  • Highly decoupled Thing Shapes system, they don't depend on a subscription pre-written with plenty of "if" conditions to check if it are needed to be triggered or not. We will generate lot's of dependencies on code becouse of this, and dependencies which aren't easily tracked.
  • Two Thing Templates on a hierarchy chain can subscribe to the same event, and this subscription can be done dynamically which will be more efficient, If I don't need it I don't suscribe ( neither I have an "If" condition ... )

Best Regards,

Carles.

1-Visitor
September 22, 2016

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

  • general: increased complexity
  • synchronization of shared resources (Things , Properties )
  • difficult to debug, result is sometimes unpredictable
  • potential deadlocks
  • "starvation": some threads may not be served with a bad design
  • constructing and synchronizing threads is CPU/memory intensive

However at same time , we also have advantages of using multi threaded environment like

  • better use of system resources
  • parallelize tasks
  • enhanced performance on multi-processor machines
  • better availability

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 .

1-Visitor
September 22, 2016

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.

1-Visitor
January 7, 2019

hi what is the official release date for 8.4 ? and where can I find that info on support site ?

1-Visitor
September 22, 2016

Thankyou Carles Coll​ for sharing your understanding and opinion. I understood the issue .

Priyanshi Saxena​ You wont be able to achieve this in Thingworx , as if now .

1-Visitor
February 23, 2017

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."

1-Visitor
February 24, 2017

For the mentioned FileTransferEvent issue there seem to be an improvement in TWX Utilities 7.3.0, see Capturing File Transfer History.