siddhi中是否可以存储应用会话数据?

问题描述

我有输入流<a href="soloplayer.html"> <div class="overlay"> <div class="text">Solo Player</div> </div> </a> 从Kafka获得输入。然后,我使用此流调用HTTP API。在HTTP呼叫响应中,我必须使用InputStream

将结果发送到另一个Kafka主题

应用流程
OutputStream(具有userId)=> InputStream => RequestHttpStream(没有userId)=> ResponseHTTPStream(此处需要userId)

问题是,我需要OutputStream才能将事件发送到userId,但是响应HTTP流OutputStream没有ResponseHTTPStream的概念。所以我正在寻找siddhi中存储和检索一些键/值映射的方法。我在siddhi中读到了userId,但似乎所有事件之间都共享它。我需要的是一个tables,仅存在于该会话中。我可以为此使用app session data吗?

代码

partitions

解决方法

您的用例是在http呼叫接收器和http呼叫响应源之间保留一个属性。这可以通过使用传输属性来实现。由于可以通过参考trp:

在源中访问接收器中的属性。
@sink(type = 'log')
@sink(type = 'http-call',sink.id = "attribution-request",publisher.url = "http://test-node-server:3031/search-attribution-id",@map(type = 'json',@payload("""{"attributionId":"{{attributionId}}"""")))
define stream RequestHttpStream(attributionId string,userId string);

@sink(type = 'log')
@source(type = 'http-call-response',http.status.code = "200",@attributes(attributes='attributes',userId='userId')))
define stream ResponseHTTPStream (attributes object,userId string);

但是请注意,由于您不想将userId发送到HTTP端点,因此必须在接收器中使用自定义映射