edgexfoundry / support-rulesengine

Owner: Core/Support WG
Apache License 2.0
19 stars 25 forks source link

rulesengine did not trigger #67

Open lcq987 opened 4 years ago

lcq987 commented 4 years ago

Hi, I want to connect the Rules Engine micro service to the data coming directly out of Core Data, but when I set the configuration parameters in application.properties file, it seems like rulesengine did not trigger. Here is my rule JSON.

{
    "name": "test",
    "condition": {
        "device": "RandomValue_Int8",
        "checks": [
            {
                "parameter": "RandomValue_Int8",
                "operand1": "Integer.parseInt(value)",
                "operation": ">",
                "operand2": 12
            }
        ]
    },
    "action": {
        "device": "56625139-1caf-4153-890f-3f87052694ed",
        "command": "d48b557b-2034-4cbc-ad2f-c20f69b7af0a",
        "body": "{\\\"message\\\":\\\"ok\\\"}"
    },
    "log": "Patlite warning triggered for engine speed too high"
}

The corresponding .dl file is as follows.

package org.edgexfoundry.rules;
global org.edgexfoundry.engine.CommandExecutor executor;
global org.edgexfoundry.support.logging.client.EdgeXLogger logger;
import org.edgexfoundry.domain.core.Event;
import org.edgexfoundry.domain.core.Reading;
import java.util.Map;
rule "test" 
when
  $e:Event($rlist: readings && device=="RandomValue_Int8")
  $r0:Reading(name=="RandomValue_Int8" && Integer.parseInt(value) > 12) from $rlist
then
executor.fireCommand("56625139-1caf-4153-890f-3f87052694ed", "d48b557b-2034-4cbc-ad2f-c20f69b7af0a", "{\"message\":\"ok\"}");
logger.info("Patlite warning triggered for engine speed too high");
end

application.properties related configuration is as follows.

#-----------------Export Service Config----------------------------------------
#Turn on/off registration of rules engine as export distro client.  
#Set to false to receive messages directly from core data
export.client=false
expect.serializedjava=false
#export.client.registration.url=http://localhost:48071/api/v1
export.client.registration.url=http://edgex-export-client:48071/api/v1
export.client.registration.name=EdgeXRulesEngine
#use port 5566 when connected to export distro
#use port 5563 when connected to core data directly
#export.zeromq.port=5566
export.zeromq.port=5563
export.zeromq.host=tcp://edgex-core-data
#export.zeromq.host=tcp://edgex-export-distro
#how long to wait to retry registration
export.client.registration.retry.time=10000
#how many times to try registration before exiting
export.client.registration.retry.attempts=100

And this is my rules engine log.

  ___    _         __  __        ___      _          ___           _          
 | __|__| |__ _ ___\ \/ /  ___  | _ \_  _| |___ ___ | __|_ _  __ _(_)_ _  ___ 
 | _|/ _` / _` / -_)>  <  |___| |   / || | / -_|_-< | _|| ' \/ _` | | ' \/ -_)
 |___\__,_\__, \___/_/\_\       |_|_\\_,_|_\___/__/ |___|_||_\__, |_|_||_\___|
          |___/                                              |___/            
/*******************************************************************************
 * Copyright 2016-2017, Dell, Inc.  All Rights Reserved.
 ******************************************************************************/

[2020-01-11 06:42:07.867] boot - 6  INFO [main] --- Application: The following profiles are active: docker
[2020-01-11 06:42:09.805] boot - 6  INFO [main] --- RuleEngine: Starting Drools with drl files from:  /edgex/edgex-support-rulesengine/rules
[2020-01-11 06:42:09.805] boot - 6  INFO [main] --- RuleEngine: Uploading Drool rules...
[2020-01-11 06:42:09.825] boot - 6  INFO [main] --- RuleEngine: ... README
[2020-01-11 06:42:09.849] boot - 6  WARN [main] --- MavenSettings: Environment variable M2_HOME is not set
[2020-01-11 06:42:11.255] boot - 6  WARN [main] --- AbstractKieModule: No files found for KieBase defaultKieBase
[2020-01-11 06:42:11.303] boot - 6  INFO [main] --- KieRepositoryImpl: KieModule was added: MemoryKieModule[releaseId=org.default:artifact:1.0.0-SNAPSHOT]
[2020-01-11 06:42:11.548] boot - 6  INFO [main] --- ExportClientImpl: Direct receiver of messages from core.  No export client registration
[2020-01-11 06:42:12.134] boot - 6  WARN [main] --- URLConfigurationSource: No URLs will be polled as dynamic configuration sources.
[2020-01-11 06:42:12.134] boot - 6  INFO [main] --- URLConfigurationSource: To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2020-01-11 06:42:12.141] boot - 6  WARN [main] --- URLConfigurationSource: No URLs will be polled as dynamic configuration sources.
[2020-01-11 06:42:12.141] boot - 6  INFO [main] --- URLConfigurationSource: To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2020-01-11 06:42:12.348] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 06:42:12.440] boot - 6  INFO [main] --- Application: Started Application in 7.012 seconds (JVM running for 7.613)
This is the Support Rules Engine Microservice.
[2020-01-11 06:42:12.512] boot - 6  INFO [main] --- ZeroMQEventSubscriber: Watching for new exported Event messages...
[2020-01-11 06:47:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 06:52:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 06:57:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:02:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:03:41.241] boot - 6  INFO [http-nio-48075-exec-1] --- RuleEngine: new rule:  test added.
[2020-01-11 07:03:41.243] boot - 6  INFO [http-nio-48075-exec-1] --- RuleEngine: Starting Drools with drl files from:  /edgex/edgex-support-rulesengine/rules
[2020-01-11 07:03:41.259] boot - 6  INFO [http-nio-48075-exec-1] --- RuleEngine: Uploading Drool rules...
[2020-01-11 07:03:41.263] boot - 6  INFO [http-nio-48075-exec-1] --- RuleEngine: ... test.drl
[2020-01-11 07:03:41.268] boot - 6  INFO [http-nio-48075-exec-1] --- RuleEngine: ... README
[2020-01-11 07:03:42.600] boot - 6  INFO [http-nio-48075-exec-1] --- KieRepositoryImpl: KieModule was added: MemoryKieModule[releaseId=org.default:artifact:1.0.0-SNAPSHOT]
[2020-01-11 07:03:42.649] boot - 6  INFO [http-nio-48075-exec-1] --- RuleEngineControllerImpl: Rule named:  test added.
[2020-01-11 07:07:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:12:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:14:43.570] boot - 6  INFO [http-nio-48075-exec-3] --- RuleEngine: rule: isoversize removed.
[2020-01-11 07:14:43.572] boot - 6  INFO [http-nio-48075-exec-3] --- RuleEngineControllerImpl: Rule named:  isoversize removed
[2020-01-11 07:14:55.517] boot - 6  INFO [http-nio-48075-exec-7] --- RuleEngine: rule: test removed.
[2020-01-11 07:14:55.518] boot - 6  INFO [http-nio-48075-exec-7] --- RuleEngineControllerImpl: Rule named:  test removed
[2020-01-11 07:15:00.976] boot - 6  INFO [http-nio-48075-exec-9] --- RuleEngine: new rule:  test added.
[2020-01-11 07:15:00.979] boot - 6  INFO [http-nio-48075-exec-9] --- RuleEngine: Starting Drools with drl files from:  /edgex/edgex-support-rulesengine/rules
[2020-01-11 07:15:00.982] boot - 6  INFO [http-nio-48075-exec-9] --- RuleEngine: Uploading Drool rules...
[2020-01-11 07:15:00.990] boot - 6  INFO [http-nio-48075-exec-9] --- RuleEngine: ... test.drl
[2020-01-11 07:15:00.992] boot - 6  INFO [http-nio-48075-exec-9] --- RuleEngine: ... isoversize.drl
[2020-01-11 07:15:00.993] boot - 6  INFO [http-nio-48075-exec-9] --- RuleEngine: ... README
[2020-01-11 07:15:01.166] boot - 6  INFO [http-nio-48075-exec-9] --- KieRepositoryImpl: KieModule was added: MemoryKieModule[releaseId=org.default:artifact:1.0.0-SNAPSHOT]
[2020-01-11 07:15:01.197] boot - 6  INFO [http-nio-48075-exec-9] --- RuleEngineControllerImpl: Rule named:  test added.
[2020-01-11 07:17:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:22:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:27:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:32:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:37:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:42:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:47:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:52:13.280] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 07:57:12.348] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 08:02:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 08:07:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 08:12:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat
[2020-01-11 08:17:12.347] boot - 6  INFO [pool-1-thread-1] --- HeartBeat: Support Rules Engine data heart beat

Thanks a lot!

Systhesis commented 4 years ago

It looks like the rulesengine didn't receive the event data.....