【问题标题】:Syntax error in SiddhiQL, no viable alternative at input '@sink'SiddhiQL 中的语法错误,输入“@sink”没有可行的替代方案
【发布时间】:2019-05-28 11:42:58
【问题描述】:

我正在尝试基于示例here 在 Siddhi 中使用 http-request(源)和 http-response(接收器)发送同步请求。

我有一个 API,我可以使用 curl 命令来访问它。这是我的 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"
}

我正在尝试使用 Siddhi 做类似的事情。

这是我的代码。

@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);

我在@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'

这里有什么我遗漏的吗?

【问题讨论】:

    标签: siddhi sendasynchronousrequest wso2sp


    【解决方案1】:

    您的接收器定义末尾缺少括号。下面是固定定义

    @sink(type='http-response', source.id='StreamSource', message.id='{{messageId}}', @map(type='json', @payload('{{results}}'))) 
    define stream SinkStream (messageId string, results String);
    

    在此之后您也会遇到问题,因为您在输入映射中只映射了 messagedID 属性。即

    @map(type='json', @attributes(messageId='trp:messageId'))
    

    请在那里也映射其他属性。

    【讨论】:

    • 感谢提山的建议。对于映射属性,文档提到使用 'trp' 作为 messageId。其他属性也应该使用相同的吗?例如:@attributes(messageId='trp:messageId', text='trp:text', project='trp:project', model='trp:model') 是这样吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-16
    • 2016-01-14
    • 1970-01-01
    • 2022-11-04
    • 2013-08-26
    • 2014-10-01
    相关资源
    最近更新 更多