我试图通过SiddhiManger获取ExectuionPlanRuntime,如下所示
public static ExecutionPlanRuntime getExecutionPlanRuntime(String plan) {
return new SiddhiManager().createExecutionPlanRuntime(plan);
}
String计划有一个表达式,它通过str:substr
WSO2CEP函数扩展名提取一个值,如下所示
define stream PROBE_DATA(speed string);
from PROBE_DATA[ convert(str:substr(speed, '(\d*)' ), 'int') > 30]
insert into ostream;
但是我得到了ExecutionPlanValidationException,说明 substr既不是函数也不是执行计划中的聚合属性
org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException: substr is neither a function nor an aggregated attribute in execution plan "ce1873e8-9247-4d16-a8ee-f9146e1e8c79"
at org.wso2.siddhi.core.util.parser.ExecutionPlanParser.parse(ExecutionPlanParser.java:127) ~[siddhi-core-3.0.2.jar:na]
at org.wso2.siddhi.core.SiddhiManager.createExecutionPlanRuntime(SiddhiManager.java:51) ~[siddhi-core-3.0.2.jar:na]
at org.wso2.siddhi.core.SiddhiManager.createExecutionPlanRuntime(SiddhiManager.java:59) ~[siddhi-core-3.0.2.jar:na]
at com.test.utils.SiddhiUtils.getExecutionPlanRuntime(SiddhiUtils.java:82) ~[SiddhiUtils.class:na]
Caused by: org.wso2.siddhi.core.exception.ExecutionPlanCreationException: substr is neither a function nor an aggregated attribute
at org.wso2.siddhi.core.util.parser.QueryParser.parse(QueryParser.java:111) ~[siddhi-core-3.0.2.jar:na]
at org.wso2.siddhi.core.util.parser.ExecutionPlanParser.parse(ExecutionPlanParser.java:117) ~[siddhi-core-3.0.2.jar:na]
... 110 common frames omitted
Caused by: org.wso2.siddhi.core.exception.ExecutionPlanCreationException: substr is neither a function nor an aggregated attribute
at org.wso2.siddhi.core.util.parser.ExpressionParser.parseExpression(ExpressionParser.java:292) ~[siddhi-core-3.0.2.jar:na]
at org.wso2.siddhi.core.util.parser.ExpressionParser.parseExpression(ExpressionParser.java:319) ~[siddhi-core-3.0.2.jar:na]
at org.wso2.siddhi.core.util.parser.ExpressionParser.parseExpression(ExpressionParser.java:123) ~[siddhi-core-3.0.2.jar:na]
at org.wso2.siddhi.core.util.parser.SingleInputStreamParser.generateProcessor(SingleInputStreamParser.java:129) ~[siddhi-core-3.0.2.jar:na]
at org.wso2.siddhi.core.util.parser.SingleInputStreamParser.parseInputStream(SingleInputStreamParser.java:86) ~[siddhi-core-3.0.2.jar:na]
at org.wso2.siddhi.core.util.parser.InputStreamParser.parse(InputStreamParser.java:51) ~[siddhi-core-3.0.2.jar:na]
at org.wso2.siddhi.core.util.parser.QueryParser.parse(QueryParser.java:64) ~[siddhi-core-3.0.2.jar:na]
... 111 common frames omitted
但是,WSO2CEP控制台的相同ExecutionPlan是有效的,如下图所示。
以下是我的siddhi pom依赖
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-core</artifactId>
<version>${siddhi.version}</version>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>org.apache.log4j.wso2</groupId>
</exclusion>
<exclusion>
<artifactId>quartz</artifactId>
<groupId>org.quartz-scheduler.wso2</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-simple</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-query-api</artifactId>
<version>${siddhi.version}</version>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>org.apache.log4j.wso2</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-query-compiler</artifactId>
<version>${siddhi.version}</version>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>org.apache.log4j.wso2</groupId>
</exclusion>
</exclusions>
</dependency>
WSO2CEP服务器是版本4.0.0,它使用的siddhi lib是版本3.0.2,但我已经尝试了版本3.0.2,3.0.3和最新的版本3.1.2 for my app client,all of all他们没有帮助,并得到了与上述相同的例外。
我是否错过了为我的应用客户端设置的内容可以识别siddhi功能扩展?
答案 0 :(得分:2)
substr
是一个返回属性的函数。因此,它不能在from
语句中应用;相反,它必须在select
语句中应用。请参阅下面的示例查询:
from inputStream
select symbol, str:substr(symbol, 4) as substring
insert into outputStream;