Drools 룰 세트를 사용하는 Java 응용 프로그램이 있습니다. 우리는 Drools 6.1을 사용하고 있습니다.Drools에서 KieScanner가 작동하지 않습니다. 6.1
룰은 Workbench 저장소에서 사용 가능합니다. Workbench를 사용하여 룰 세트를 변경할 때 결과의 변경 사항을 확인하고자합니다. 그래서 자바 코드에서 주기적으로이 기계를 검사하는 Kiescanner 모듈을 추가했지만 성공하지 못했습니다.
우리의 자바 코드
package com.sample;
import org.drools.compiler.kproject.ReleaseIdImpl;
import org.kie.api.KieBase;
import org.kie.api.KieServices;
import org.kie.api.builder.KieScanner;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import com.drools.project1.inputs;
/**
* This is a sample class to launch a rule.
*/
public class DroolsTest {
public static final void main(String[] args) {
try {
KieServices ks = KieServices.Factory.get();
ReleaseIdImpl releaseId = new ReleaseIdImpl("com.drools",
"project1", "LATEST");
KieContainer kieContainer = ks.newKieContainer(releaseId);
KieScanner kieScanner = ks.newKieScanner(kieContainer);
kieScanner.start(1000L);
while (true) {
KieBase kBase = kieContainer.getKieBase();
KieSession kSession = kBase.newKieSession();
inputs types = new inputs();
types.setNum1(50);
kSession.insert(types);
kSession.fireAllRules();
kSession.destroy();
Thread.sleep(1000);
System.out.println("getNum2 = " + types.getNum2());
}
} catch (Throwable t) {
t.printStackTrace();
System.err.println(t);
System.err.println("Cause = " + t.getCause());
}
}
}
우리는 다음과 같은 방법으로 우리의 pom.xml과 Settings.XML의 파일을 만들었습니다.
의 pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample</groupId>
<artifactId>DroolsMaven</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Drools :: Sample Maven Project</name>
<description>A sample Drools Maven project</description>
<distributionManagement>
<repository>
<id>drools</id>
<name>Internal Releases</name>
<url>http://foo.com/kie-drools-wb-distribution/maven2</url>
</repository>
</distributionManagement>
<dependencies>
<!-- CDI dependencies -->
<!-- END -->
<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>javax.xml.parsers</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4.5</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.org.apache</groupId>
<artifactId>jaxp-ri</artifactId>
<version>1.4</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>javax.xml.soap-api</artifactId>
<version>1.3.6</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xerces</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.xml.rpc</artifactId>
<version>3.1.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.4</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.drools</groupId>
<artifactId>project1</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/WEB-INF/lib/project1-1.0.jar</systemPath>
</dependency>
</dependencies>
<repositories>
<repository>
<id>my-local-repo</id>
<url>file://${project.basedir}/src/main/webapp/WEB-INF/lib</url>
</repository>
</repositories>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</extension>
</extensions>
<finalName>NAME_OF_THE_GENERATED_WAR</finalName>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>6.1.0.Final</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<project>
1.6
</project>
<source>1.6</source>
<target>1.6</target>
<encoding>Cp1254</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<encoding>Cp1254</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<outputDirectory>${basedir}/target/generatedWAR</outputDirectory>
<tasks>
<echo>Echo : This is maven-war-plugin</echo>
</tasks>
</configuration>
</plugin>
</plugins>
</build>
</project>
한편 Settings.XML의
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>C:\Devel\m2repo</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>guvnor-m2-repo</id>
<username>user</username>
<password>pass</password>
</server>
</servers>
<mirrors>
<mirror>
<id>guvnor-m2-repo</id>
<url>http://foo.com/kie-drools-wb-distribution/maven2</url>
<mirrorOf>*</mirrorOf>
</mirror>
<mirror>
<id>nexus</id>
<url>http://10.145.3.107:8081/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>snapshots</id>
<url>http://10.145.3.107:8081/nexus/content/repositories/snapshots</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>profile-1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>drools</id>
<url>http://foo.com/kie-drools-wb-distribution/maven2</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
</repositories>
</profile>
<profile>
<id>a.profile</id>
<properties>
<a.property>this is a property</a.property>
</properties>
</profile>
<profile>
<id>b.profile</id>
<properties>
<b.property>this is another property</b.property>
</properties>
</profile>
</profiles>
<!-- activeProfiles | List of profiles that are active for all builds. | -->
<activeProfiles>
<activeProfile>profile-1</activeProfile>
</activeProfiles>
</settings>
코드가있을 때 우리는 최신 로컬 저장소의 버전 또는 "resolver-status.properties"파일을 삭제하는 경우 실행 중이면 새 버전이 원격 시스템에서 로컬로 자동 다운로드됩니다. 그러나 Workbench에서 새 버전을 작성하면 프로그램이이를 감지하지 못합니다.
설명을 잘못 기재 할 수 있습니까?
귀하의 조언에 감사드립니다.