Синтаксическая ошибка в SiddhiQL, нет реальной альтернативы при вводе '@sink' - PullRequest
0 голосов
/ 28 мая 2019

Я пытаюсь отправить синхронный запрос, используя http-запрос (источник) и http-ответ (приемник) в сиддхи на основе примера здесь .

У меня есть 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"
}

Я пытаюсь сделать нечто подобное, используя Сиддхи.

Это мой код.

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

Есть ли что-то, что я здесь упускаю?

1 Ответ

1 голос
/ 28 мая 2019

Вам не хватает скобок в конце определения раковины.Ниже приведено фиксированное определение

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

. После этого вы также столкнетесь с проблемами, поскольку в отображении входных данных у вас есть только атрибут mapped messagedID.то есть

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

Пожалуйста, укажите там другие атрибуты.

...