Rules Engine stops working

Hi, i’ve been testing my openremote platform for some time and it appears to be a problem with the rules engine. In about 20 days of use, the rules stops working but the map and other things works well. Any ideas? Thanks

It would help if you copy your rules here. Some rules constructs can cause problems.

1 Like

Hi Michal,
this is the rule:

package DHT11.rules

import org.openremote.model.query.AssetQuery
import org.openremote.manager.rules.RulesBuilder
import org.openremote.model.asset.*
import org.openremote.model.attribute.*
import org.openremote.model.value.*
import org.openremote.model.rules.*
import java.util.logging.*

Logger LOG = binding.LOG
RulesBuilder rules = binding.rules
Assets assets = binding.assets

rules.add()
        .name("Estado DHT11")
        .when(
            {facts ->
            facts.matchAssetEvent(
                new AssetQuery()
                    .ids("2y18SxBPdZtFxhEe1wHxzl")
                    .attributeName("estado")
            ).count() == 0 && !facts.matchFirst(String, {it == "VirtualSensor2"}).isPresent()
        })
        .then(
            {facts ->
            assets.dispatch(new AttributeEvent("2y18SxBPdZtFxhEe1wHxzl", "estado", "Desconectado"))
            facts.putTemporary("PT1M", "VirtualSensor2")
        })

This rule updates the state of a device when it does not communicate after 1 minute. It appears to work well. Thanks!

Unfortunately, my knowledge of this rule system is very limited and I don’t see any obvious errors. Nevertheless, if the system stops working after longer time it usually signals some kind of memory leak and OOM errors. Because you are calling new on RHS of the rule then make sure that it is properly garbage collected.

1 Like