Order of rule execution if item is updated quickly

Hi,

let’s assume I have a Rule reacting on updates on some Item and get multiple updates on the Item, is there a way to enforce that the Rules are executed in the right order?

dero

Not really. All of these things happen in a multithreaded environment so it is up to the CPU scheduler to determine order.

However, if you explain your use case perhaps there is another way to get the same behavior you are after.

Real or virtual devices with high frequency updates.

Independent of any use case, the inability to maintain at least partial ordering is a very, very bad design decision for a distributed system and will cause non-deterministic behavior.

At least, on a single item, maintaining ordering is an essential requirement.

When you asked the question I assumed you were referring to Events coming from different Items and somehow ordering the execution of Events from different Items.

If you are just talking about events from a single Item then OH is not a good fit for you. Frankly, if you are pounding the Event bus with events from a single Item that receives updates so fast that they do not naturally process in order then OH is not going to be a good fit for your use case. You need lot look into some system that supports Real-Time processing (Windriver’s products are a good place to start). OH is not a realtime system and is not intended to be used as such.

Usually, the events that a single Item generates are no closer together than several seconds apart. At that rate ordering is naturally preserved. But there are no controls in place to guarantee this and if you get too close together (milliseconds) two separate Event process threads will be selected to process the events in parallel. And even then, for that vast majority of Home Automation problems, the fact that theses events are processed out of order is not a problem either.

So, I would suggest that if you have a case where you have a single Item generating events that fast you should move that processing outside of OH and batch up the results or somehow otherwise filter them so OH gets the information it needs at a slower rate.

It depends on the problem the architecture is intended to address. For Home Automation or some other non-realtime system events typically occur slowly enough that order is naturally preserved. In those rare cases where it isn’t usually the fact they are processed out of order doesn’t matter. The determinism is naturally preserved.

If your use case depends on this then OH is not the architecture for you. That doesn’t make is a bad architecture.

For you it may be. For every home automation use case I can think of, events from a single Item come in slowly enough that they naturally are processed in order without technical controls in place to enforce that.

Remember:

  • OH is not an industrial control hub
  • OH is not a realtime event processing hub
  • OH is not an embedded control system for a robot or a car or the like
  • OH is designed to support home automation, and it does so fantastically well.
2 Likes