简体   繁体   English

DROOLS规则引擎:在Drools中进行网络调用

[英]DROOLS Rule Engine : Making network calls within Drools

One of the transactional systems i work upon deals with data-gathering from multiple external systems, and making some business decision based upon the (transactional entity + gathered-data). 我工作的事务系统之一处理来自多个外部系统的数据收集 ,并基于(事务实体+收集的数据)做出一些业务决策。

Currently , we follow the following steps: 目前,我们遵循以下步骤:

  1. Gathering data from multiple sub-systems. 收集来自多个子系统的数据。

  2. Using (Gathered data + transactional entity) as an input to drools, and deriving a business decision out of it. 使用(收集的数据+交易实体)作为流口水的输入,并从中得出业务决策。

One major cons of the above approach is that i have to gather all the data beforehand (expensive network calls) without even bothering about the usefulness of the data. 上述方法的主要缺点是,我必须事先收集所有数据(昂贵的网络呼叫),而不必担心数据的有用性。

What i am trying to do is to delay the service calls by moving it to the rule execution layer. 我正在尝试做的是通过将服务调用移至规则执行层来延迟服务调用。 The intention is to leverage the drools decision tree to avoid making a service call if i can take a decision on some already available data (within my transactional entity itself). 如果我可以对某些已经可用的数据(在我的交易实体本身内)做出决定,则可以利用流口水的决策树来避免进行服务调用。

Just want to get the thought process validated (ie, making a service call as part of the rules execution would be a good practice or not.). 只是想让思考过程得到验证(即,将服务调用作为规则执行的一部分将是一个好习惯,或者不是一个好习惯。)。

Can anybody please share the pros/cons around the same. 任何人都可以分享相同的优点/缺点。 Any leads would be appreciated 任何线索将不胜感激

You cannot reason with facts you don't have (yet). 您无法用您还没有的事实进行推理。 If the facts you do have let you decide what else you need you can write rules according to the following trivial example. 如果您确实掌握了事实,那么可以根据以下琐碎的示例来编写规则。

rule "x and y, not z"
when
    Dimension( $id: id, coord == "x" )
    Dimension( id == $id, coord == "y" )
    not Dimension( id == $id, coord == "z" )
then
    fetch and insert missing Dimension
end

rule "x, y and z" ... end

Note that this process of fetching and inserting must not be executed synchronously. 请注意,此提取和插入过程一定不能同步执行。 You can insert the request as an event queue - use anything from Java. 您可以将请求插入为事件队列-使用Java中的任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM