- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Ciao,我已经测试了几种方法,但我仍然无法在Drools Fusion中测试和验证事件过期机制,所以我正在寻找一些指导,好吗?
我已经阅读了手册,我对这个功能很感兴趣:
In other words, one an event is inserted into the working memory, it is possible for the engine to find out when an event can no longer match other facts and automatically retract it, releasing its associated resources.
public class DroolsTest {
public static final void main(String[] args) {
try {
KnowledgeBase kbase = readKnowledgeBase();
// I do want the pseudo clock
KnowledgeSessionConfiguration conf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
conf.setOption(ClockTypeOption.get("pseudo"));
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(conf, null);
SessionPseudoClock clock = ksession.getSessionClock();
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
// Insert of 2 Event:
Message message = new Message();
message.setMessage("Message 1");
message.setStatus(Message.HELLO);
ksession.insert(message);
ksession.fireAllRules();
clock.advanceTime(1, TimeUnit.DAYS);
Message message2 = new Message();
message2.setMessage("Message 2");
message2.setStatus(Message.HELLO);
ksession.insert(message2);
ksession.fireAllRules();
clock.advanceTime(1, TimeUnit.DAYS);
ksession.fireAllRules();
// Now I do check what I have in the working memory and if EventFactHandle if it's expired or not:
for (FactHandle f : ksession.getFactHandles()) {
if (f instanceof EventFactHandle) {
System.out.println(((EventFactHandle)f)+" "+((EventFactHandle)f).isExpired());
} else {
System.out.println("not an Event: "+f);
}
}
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
// following 2 lines is the template code modified for STREAM configuration
KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption( EventProcessingOption.STREAM );
return kbase;
}
/*
* This is OK from template, as from the doc:
* By default, the timestamp for a given event is read from the Session Clock and assigned to the event at the time the event is inserted into the working memory.
*/
public static class Message {
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
}
}
}
package com.sample
import com.sample.DroolsTest.Message;
declare Message
@role(event)
end
declare window LastMessageWindow
Message() over window:length(1)
end
rule "Hello World"
when
accumulate( $m : Message(status==Message.HELLO) from window LastMessageWindow,
$messages : collectList( $m ) )
then
System.out.println( ((Message)$messages.get(0)).getMessage() );
end
@expires(1s)
最佳答案
找到解决方案!显然是我愚蠢,没有意识到我在使用 Drools 5.4.0.Final,同时仍然引用 5.2.0.Final 的旧文档。在 Drools Fusion 5.4.0.Final 的更新文档中,为 添加了此框2.6.2.滑动长度窗 :
Please note that length based windows do not define temporal constraints for event expiration from the session, and the engine will not consider them. If events have no other rules defining temporal constraints and no explicit expiration policy, the engine will keep them in the session indefinitely.
Message() over window:length(1)
关于drools - Drools Fusion CEP 中的测试事件到期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12338385/
通过Dropbox oAuth2 API获取的访问 token 的生存期是多少? https://api.dropbox.com/1/oauth2/token之后的答案类似于 { "acces
在 Braintree 中,当我生成带有 $customerId 的客户端 token 时,将该客户端 token 保存到数据库并在以后重新使用它有多可靠? 我总是有一个用户对应一个 $custome
我是新手,正在尝试编写一个简单的登录应用程序。当我离开登录页面一段时间并输入用户名和密码时,它不会登录,而是会执行 session 过期行为。我检查了日志,发现每当我收到 INFO - Session
我想导航到刷新 token 过期时的登录 View 。我如何在Android中使用 OkHttp 处理这种情况。刷新 token 到期时,服务器以错误代码 403禁止的响应。有什么方法可以处理刷新 t
我想知道 Backbone 模型/ Controller 是否有一种标准方法来处理 session 结束。我正在使用 node.js 作为我的 webapp 的后端,现在我将 session 存储在内
我正在使用 https://www.paypal.com/cgi-bin/webscr 用于进行 PayPal 付款。当任何用户点击 PayNow 按钮时,它将导航到用户输入其凭据的 PayPal 页
我们最近注册了一个 iOS Enterprise 帐户用于内部应用分发。 搜索论坛发现两件事我想得到确认: 1- 企业分发证书有效期为 3 年。这是否意味着我们需要在此时使用新证书重新构建应用程序,否
我遇到了一个奇怪的场景。基本上在我正在做的每个网页上 session_start(); if(!isset($_SESSION['login'])) header("Location: log
有许多工具可用于监控通过 HTTPS 提供的服务的 SSL 过期,例如我们使用 https://github.com/prometheus/blackbox_exporter当 SSL 证书在内部和外
我正在使用 Vapor 4 开发一个 Web 应用程序。在请求之间一次将客户端制作的数据保存在服务器端几分钟会很有用。我想使用 session 来做到这一点。但是,我对如何在设定时间后自动销毁这些数据
我正在使用带有自定义身份验证的 firebase 9.x。根据文档, token 到期时间不能超过一小时。是否有一个我可以注册的监听器,当 token 过期时将调用它。 该文档还讨论了 token 的
正在关注 http://code.google.com/apis/gmail/oauth/protocol.html#imap我正在尝试为使用 OAuth 的 Gmail 实现 IMAP 客户端。 我
试图确定是否由对 Accounts.sendResetPasswordEmail() 的调用生成的 token 将永远过期。我在 accounts-password 上找不到任何进一步的文档。包超出了
编辑:我对这本书的当前状态不感兴趣。这是各种结账的历史记录。 实际上,整个问题可能格式错误,无法回答。但无论如何我得到了答案,这很好。我主要是在寻找WHEN -> THEN结构。 我有books可以检
根据我的理解,在使用 Drive Java API 时,建议构建一个 Drive 类的实例,然后存储它,以便其他线程可以共享它。如果持有对 Drive 实例的引用的进程是一个长时间运行的进程(即无限期
我读到的关于 cookie 的所有内容都说,将 cookie 的到期时间设置为零应该使其成为“ session ”cookie,浏览器将在退出时将其删除。 http://www.cookiecentr
我正在制作一个使用jwt来验证数据库调用的 Angular 应用程序。 就是当 token 在服务器上过期时,由于过期的 token 仍在本地存储中,因此应用程序开始提供空白页而不是数据。经过一些研究
我在grails应用程序中使用spring安全性。在其他浏览器上使用相同的用户名登录时,我需要使上一个 session 到期。并发 session 限制是否有帮助?这该怎么做? 最佳答案 I need
当我向手机发送推送通知时遇到了麻烦,它返回了以下错误: [X-SubscriptionStatus] => Expired [X-NotificationStatus] => Dropped [X-D
我需要创建一个用户登录/注销/ session 到期跟踪页面(ASP.Net)..很明显,当用户登录和注销时,我可以调用我的跟踪页面。如何检测 session 过期? 最佳答案 在有状态应用程序中,最
我是一名优秀的程序员,十分优秀!