如何在 jersey rest web 服务中集成 drools如何在、jersey、rest、web

2023-09-06 15:07:36 作者:仅存的一点任性

我开发了一个 jersey est 网络服务 API.现在我想在这个休息服务中集成 DROOLS 规则.在其余服务中,在确定所有必需条件后,我想将其发送到 drools 规则引擎并触发规则.这个怎么做.请帮我一步一步指导.

I have developed a jersey est web service API. Now I would like to integrate DROOLS rules in this rest service. IN the rest service, after ascertaining all required conditions, i would like to send it to the drools rule engine and the fire the rule. How to do this. Please help me step by step guidance.

推荐答案

这不是 Jersey,但这里是一个 REST Web 服务的示例,它使用 Drools 评估请求:https://github.com/gratiartis/sctrcd-payment-validation-web

It's not Jersey, but here is an example of a REST web service, which evaluates requests using Drools: https://github.com/gratiartis/sctrcd-payment-validation-web

实际上,您创建了一个封装知识库的单例 bean.当验证请求到达时,您可以创建知识会话、插入事实并执行规则.

Essentially you create a singleton bean, which wraps the knowledge base. When validation requests arrive, you can create knowledge sessions, insert your facts and execute the rules.

它是使用 Spring 构建的,因此如果不使用 Spring,您需要进行的主要更改是确保知识库只创建一次.

It's built with Spring, so the main change you would need to make if not using Spring would be to ensure that the knowledge base is only created once.