我正在尝试使用WSO2 Streaming Integrator / Siddhi解析JSON事件流,但似乎未能正确地将事件放入流中。我正在使用dockerimage wso2/streaming-integrator:1.0.0
对其进行运行。
我正在将以下输入流发送到SiddhiApp(作为HTTP POST到Siddhi端点):
[
[ 1502942400000, "4261.480" ],
[ 1503982400000, "1010.312" ]
]
我的流定义如下:
@source(type='http', receiver.url='http://0.0.0.0:5010/stream', @map(type='json', @attributes(
timestamp = "[0]", sensorvalue = "[1]"
)))
define stream SensorAlertsStream (
timestamp long,
sensorvalue double,
我正在使用邮递员将数据发送到WSO2 Streaming Integrator,但是我得到的只是错误或根本没有响应。
我尝试了以下属性配置,但均未成功:-时间戳=“ $。[0]”,传感器值=“ $。[1]”-时间戳=“ $ [0]”,传感器值=“ $ [1]”-时间戳=“ $ [0] [0]”,传感器值=“ $ [0] [1]”-时间戳=“ [0]”,传感器值=“ [1]”
我是否在源定义或映射属性中缺少某些内容,或者我应该得出结论,使用siddhi-json映射无法解析此数组输入结构?
如果有帮助,这是我的简化应用程序定义:
@App:name("SO-SensorApp")
@source(type='http', receiver.url='http://0.0.0.0:5010/stream', @map(type='json', enclosing.element="$[0]", @attributes( timestamp = "[0]", sensorvalue = "[1]" )) )
define stream SensorAlertsStream ( timestamp long, sensorvalue double );
@sink(type='log', @map(type='json'))
define stream log_values( sensorvalue double );
from SensorAlertsStream select sensorvalue insert into log_values;
我在Siddhi Tooling 5.1.2中使用siddhi-map-json-5.0.6对此进行了测试,通过以下配置可以解决此问题,enclosing.element-'$',时间戳=“ [0]”,sensorvalue =“ [1 ]“
@source(type = 'http', receiver.url = 'http://0.0.0.0:8007/stream',
@map(type = 'json', enclosing.element = "$",
@attributes( timestamp = "[0]", sensorvalue = "[1]" )) )
@sink(type = 'log')
define stream SensorAlertsStream1 ( timestamp long, sensorvalue double );