不匹配的输入 '.'在规则

mismatched input '.' in rule

我是 drools 的新手。我正在写一个新的 rule.But 我收到如下错误:

mismatched input '.' in rule "StopTextRule" in pattern

我的规则是

package com.******.*****;

import java.lang.Number;

rule "StopTextRule"
    dialect "mvel"
    salience 20
    lock-on-active true
    when
        RoutingData( messageBody != null && (
                        (messageBody.trim().equalsIgnoreCase("stop") || messageBody.trim().equalsIgnoreCase("\"stop\"") || messageBody.trim().equalsIgnoreCase("stop.") || messageBody.trim().equalsIgnoreCase("\"stop.\"")) 
                            || (messageBody.trim().equalsIgnoreCase("quit")|| messageBody.trim().equalsIgnoreCase("\"quit\"") || messageBody.trim().equalsIgnoreCase("quit.")|| messageBody.trim().equalsIgnoreCase("\"quit.\""))
                            || (messageBody.trim().equalsIgnoreCase("cancel")|| messageBody.trim().equalsIgnoreCase("\"cancel\"") || messageBody.trim().equalsIgnoreCase("cancel.")|| messageBody.trim().equalsIgnoreCase("\"cancel.\""))
                            || (messageBody.trim().equalsIgnoreCase("UNSUBSCRIBE")|| messageBody.trim().equalsIgnoreCase("\"UNSUBSCRIBE\"") || messageBody.trim().equalsIgnoreCase("UNSUBSCRIBE.")|| messageBody.trim().equalsIgnoreCase("\"UNSUBSCRIBE.\"")))
                            && incomingMessageProtocol != null && incomingMessageProtocol.trim().equalsIgnoreCase("X"))
        routingResp : RoutingRuleResponse( isStop == false )
    then
        modify( routingResp ) {
                setIsStop( true )
        }
end

这使用 Drools 6.4.0 编译。我认为您使用的是旧版本,其中 Java 表达式必须包含在 eval.

无论如何重写这个模式都会更简单:

rule x
when
   X( messageBody != null &&
      messageBody matches "\s*(\"?)(?i:stop|quit|cancel|unsubscribe)\.?\1\s*" &&
      incomingMessageProtocol != null &&
      incomingMessageProtocol matches "\s*(?i:X)\s*") )
then
   // ...
end