[SOLVED] Concurrent Rules

My setup is arranged in subsections with seperate files for items, rules, sitemaps etc. For example there are seperate rule files for water meter and electricity meter.

Now I have this question:
Do I have to expect problems when rules in different rule files are triggered concurrently?
I would like to use multiple rules in different files like this

rule "rule_waterMeter_Midnight"
    when
        Time is midnight
     then
        // do something
end

The do sections of the rules don’t interfere with each other as they only deal with items specific for the water meter for example.

Of course I easily could avoid this by moving each rule to a slightly different trigger time, e.g. 1, 2, 3… minutes after midnight. But this doesn’t seem to be very elegant.

Neverming the elegance.
The stability of your system in more important.
If you have many rules starting at midnight exactly, openHAB only have concurent 5 threads. So only 5 rules would execute at a time. That’s not counting the system and binding events that may or may not occur at midnight. For example, the Astro binding performs the daily calculations at 30s past midnight to avoid this kind of conflict.
I have rules that need to run daily.
I perform them a few minutes past midnight and at a different time each. This allow the rules to run and the logs are much easier to read.

I also tend to to daily times calculations a few minutes past 2am to avoid the summer time change problems.

Thanks a lot for this information. I was not aware of the fact that openHAB is limited concerning the number of concurrent threads.
So I’ll schedule the triggers consecutively to avoid running into problems.

Please mark the topic as solved, thanks

Done.

Actually, until recently, there were only 2 threads allocated to run cron rules. This was recently increased to 10, but can also be modified to whatever value is desired.

See here for discussion.

Where to i modify this value?
Running oH 2.4.0-1

Stop openHAB, then in runtime/etc/quartz.properties, change the value assigned to org.quartz.threadPool.threadCount, then restart openHAB.

1 Like