[英]Syntax error in SiddhiQL, no viable alternative at input '@sink'
I'm trying to send a synchronous request using http-request (source) and http-response (sink) in Siddhi based on an example here . 我正在尝试根据此处的示例在Siddhi中使用http-request(源)和http-response(接收器)发送同步请求。
I have an API, which I'm able to hit using a curl command. 我有一个API,可以使用curl命令进行访问。 This is my curl command and the output. 这是我的curl命令和输出。
curl http://localhost/parser/ -d '{"q":"test input", "project":"sample_project","model":"sample_model"}'
{
"intent": {
"name": "Cat A",
"confidence": 0.7
},
"entities": [],
"intent_ranking": [
{
"name": "Cat A",
"confidence": 0.7
},
{
"name": "Cat B",
"confidence": 0.6
},
{
"name": "Cat C",
"confidence": 0.01
],
"text": "test input",
"project": "sample_project",
"model": "sample_model"
}
I'm trying to do something similar using Siddhi. 我正在尝试使用Siddhi做类似的事情。
This is my code. 这是我的代码。
@source(type='http-request', source.id='StreamSource', receiver.url='http://localhost/parser', connection.timeout='150000', @map(type='json', @attributes(messageId='trp:messageId')))
define stream SourceStream (messageId string, text string, project string, model string);
@sink(type='http-response', source.id='StreamSource', message.id='{{messageId}}', @map(type='json', @payload('{{results}}')) define stream SinkStream (messageId string, results String);
The error I'm getting in the @sink line is that: 我在@sink行中遇到的错误是:
Syntax error in SiddhiQL, no viable alternative at input ';\r\n\r\n@sink(type='http-response', source.id='StockStreamSource', message.id='{{messageId}}', @map(type='json', @payload('{{results}}')) define'. no viable alternative at input ';\r\n\r\n@sink(type='http-response', source.id='StockStreamSource', message.id='{{messageId}}', @map(type='json', @payload('{{results}}')) define'
Is there something I'm missing here? 我在这里想念什么吗?
You are missing parentheses at the end of your sink definition. 在接收器定义的末尾缺少括号。 Below is the fixed definition 以下是固定定义
@sink(type='http-response', source.id='StreamSource', message.id='{{messageId}}', @map(type='json', @payload('{{results}}')))
define stream SinkStream (messageId string, results String);
You will face issues after this also as you have only mapped messagedID attribute in your input mapping. 在这之后,您还将面临问题,因为您在输入映射中仅映射了messagedID属性。 ie 即
@map(type='json', @attributes(messageId='trp:messageId'))
Please map other attributes as well there. 请在那里也映射其他属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.