English 中文(简体)
从 Java 客户端调用 Ilog Jrution 规则执行服务器
原标题:Calling Ilog Jrule Rules Execution server from java client

我试图执行IBM Jrules 规则执行服务器的规则, 使用 java 客户端。 我拥有Websphere 社区版V2.1 服务器, 我能够使用撒玛利亚服务器上部署的 JSF 来拨打并执行规则 。

我想用Java客户打电话来 执行规则

在 EJB 中,我们可以从网络和 Java 客户中给 EJB 打电话, 设置初始背景嫉妒属性。 是否有类似的方法可以使用 java 客户来称呼规则执行服务器规则, 网络部分已经起作用了 。

import ilog.rules.res.session.IlrPOJOSessionFactory;
import ilog.rules.res.session.IlrStatelessSession;
import ilog.rules.res.session.IlrSessionFactory;
import ilog.rules.res.session.IlrStatefulSession;
import ilog.rules.res.session.IlrSessionRequest;
import ilog.rules.res.session.IlrJ2SESessionFactory;
import ilog.rules.res.session.IlrSessionResponse;
import ilog.rules.res.model.IlrPath;
import ilog.rules.res.session.extension.IlrExtendedJ2SESessionFactory;
import miniloan.Borrower;
import miniloan.Loan;

public class POJOEx {

    public static void main(String... arg) {
        // create rule session factory
        //IlrSessionFactory sessionFactory = new IlrPOJOSessionFactory();
        //IlrExtendedJ2SESessionFactory sessionFactory = new IlrExtendedJ2SESessionFactory();
        //      j2se factory
        IlrSessionFactory sessionFactory = new IlrJ2SESessionFactory();

        try {
            // use stateless session for invocation
            IlrStatelessSession statelessSession = sessionFactory.createStatelessSession();
//input parameter
            Borrower borrower = new miniloan.Borrower("Joe", 600,
                    80000);
// in out parameter
            Loan loan = new miniloan.Loan(500000, 240, 0.05);

            IlrSessionRequest request = sessionFactory.createRequest();
//rule path
            request.setRulesetPath(IlrPath.parsePath("/miniloanruleapp/2.0/miniloanrules/1.0"));

request.setUserDat("miniloanruleapp.MiniloanrulesclientRunnerImpl.executeminiloanrules");

            request.setInputParameter("borrower", borrower);
            request.setInputParameter("loan", loan);
//executing 
            IlrSessionResponse response = statelessSession.execute(request);

            System.out.println("userdata = " + response.getOutputParameters().get("loan"));
            System.out.println("outputString = " + (String) response.getUserData());
            System.out.println("executionId  = " + response.getExecutionId());


        } catch (Exception ex) {
            ex.printStackTrace();
        }          

    }
}

我越来越低 错误。

ilog.rules.res.xu.ruleset.impl.archive.IlrRulesetArchiveInformationNotFoundException: Cannot get the information about the ruleset /miniloanruleapp/2.0/miniloanrules/1.0

任何人都可以建议在哪里指定规则执行服务器 URL、用户名和密码。 就像我们在 EJB 中指定初始 Ctext 值一样 。

问题回答


Let me clarify what is RES because it seems there is a misunderstanding here, it may be me.
RES is used in Ilog terminology to describe multiple things:
- The web interface that allows you to manage your ruleapp.
- The actual application that you deploy on your WebSphere CE (or else) in order to execute the rules.
- The .jar files that allows you to execute the ruleapp locally.

You, AFAIK, cannot connect RES using a local JAVA application.
What you have coded is calling the rule engine contained in the RES*.jar files in order to execute your ruleapp locally.
There is no way you can use your JAVA application like you are using your EJB application.
You have to use a webservice or else which is feasible if you put the ruleapp name as a parameter of the web service for instance.
You are using miniloan so you probably know the example using the web interface where you can tell which version of the ruleset to use.
It will be the same if you want to programmatically manage your ruleapp deployed on RES (real application on your application server) you will need to use MDB. Nothing else.

It is disapointing, I know because I went through that, but there is no way I know (at least) to do that. This is not the behaviour you have to follow.

To make it work then put your ruleapp in the classpath (or root of your JAVA application in eclipse) and run it... Then you will execute your rules.

RES doesn t provide the same tools than RTS where you can access RTS from any JAVA application in order to manipulate your rule project.

You are 100% correct there is no way to tell the J2SE connection what is the server URL and hence no way to run your rules from the server.
Hope it helps.

您可以从 J2EE 代码中或者从您的远程 J2SE 呼叫中, 直接调用规则执行服务器, 并且为此提供了文件。 但我确实想澄清一些关于第一次回应的事宜 。

规则执行服务器是执行规则的运行时间。 它有一个持久性层( 文件或数据库)和一个管理控制台, 用来管理它和任何其他连接的规则执行服务器 。

使用 :

  • server:port/res URL

您无法连接到一个实际的RES, 因为您可以连接许多RES到一个管理控制台。 管理控制台拥有关于持久性层的详细信息, 并且可以提取您想要执行的规则 。

对于您的问题。 您正在获取错误的原因是您尚未配置您想要从哪个远程规则执行服务器中拉出规则, 这就是为什么您得到了您所看到的错误 。

要配置远程连接, 请使用名为 RA. xml 的文件, 并更改设置以指向您的远程 Res/ concole 。

/ 执行服务器/ 宾目录中有默认的 ra. xml (默认为 // IBM/ ODM87/ ODM/ 执行服务器/ bin) 。

该文件中需要考虑的主要方面是:

  To enable management of Java SE XU instances that are running on different JVM or JMX MBean server, you must configure the  XU MBean plug-in with the TCPIP protocol:
    <config-property>
               <config-property-name>plugins</config-property-name>
               <config-property-type>java.lang.String</config-property-type>
               <config-property-value>{pluginClass=Management,xuName=default,protocol=tcpip,tcpip.port=TCPIP_PORT,tcpip.host=RES_CONSOLE_HOST,tcpip.retryInterval=INTERVAL}
          </config-property-value>
        </config-property>
    where:
RES_CONSOLE_HOST is the host on which the Rule Execution Server console is deployed.
TCPIP_PORT is the TCP/IP port on which the Rule Execution Server console management server is listening.
INTERVAL is the interval of time, in milliseconds, during which the console tries to reconnect to the management server if a connection fails.

只要 ra.xml 处于您正在运行的应用程序的类路径中, 本地 J2SE 引擎应该呼叫远程 RES 控制台, 并请求提供 RulesSet 路径中指定的规则应用程序 。

J2EE, 这是相似的, 但你实际上执行规则 在远程 RES 而不是拉当地的规则。

如果您检查了 ODM 样本, 有 J2EE 和 J2SE 的样本可以展示两种技术。

adding below files in the same folder of *.dsar worked for me creation_date.txt, display_name.txt, properties.txt





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签