悉地流无模式数据



我有一个来自 ActiveMQ 的源数据,我遇到的问题是这些数据没有固定的结构,因此,当我定义流时,它会抛出一个不兼容的数据类型错误,有没有办法通过某种条件来调节源流?

提前谢谢。

/*
* Origin of data.
*/
@source(type='jms',
@map(type='csv', delimiter=',', fail.on.unknown.attribute='false'),
factory.initial='org.apache.activemq.jndi.ActiveMQInitialContextFactory',
provider.url='tcp://127.0.0.1:61616',
destination='simulatedData',
connection.factory.type='queue',
connection.factory.jndi.name='QueueConnectionFactory',
transport.jms.SubscriptionDurable='true',
transport.jms.DurableSubscriberClientID='wso2SPclient1')

define stream FileSourceProductionStream(type string, time long, studentId string, fileId string, totalAccesses float); /* totalAccesses : float Incompatible DataType*/
define stream TaskSourceProductionStream(type string, time long, studentId string, taskId string, deadline long); /*deadline: long Incompatible DataType*/

在 siddhi 中,源流应该具有输入数据的架构。因此,我们不能将无模式数据接收到定义的流中。

适用于您的方案的一种可能的解决方案是定义一个包含所有可能的输入属性的流,并将输入预先格式化为 JSON[1]、XML[2] 或 TEXT[3] 格式,这些格式由 siddhi-map 扩展支持,并具有属性名称和值。对于缺少的属性,json/xml/text 输入有效负载中不会有键或标记。

然后在源配置中使用 @map(fail.on.missing.attributes='false( 配置。

然后,对于输入有效负载中所有缺少的属性,NULL 将分配给输入流的相应属性。

[1] https://wso2-extensions.github.io/siddhi-map-json/api/4.0.20/

[2] https://wso2-extensions.github.io/siddhi-map-xml/api/4.0.12/

[3] https://wso2-extensions.github.io/siddhi-map-text/api/1.0.16/

最新更新