2

WSO2 SP 4.3.0 似乎不适用于大于 1024 个字符的 JSON 事件。有什么限制吗?

我正在使用 WSO2 流处理器版本 4.3.0。我有一个使用带有 JSON 映射的 HTTP 源部署的 Shiddi 应用程序。只要 JSON 事件少于 1024 个字符,一切正常。如果 JSON 的长度超过 1024 个字符,那么看起来 SP 正在将消息拆分为几个不同的事件,并且在尝试解析 JSON 内容时失败。

使用包含的示例“ReceiveHTTPInJsonFormatWithDefaultMapping”很容易重现。

@Source(type = 'http', receiver.url='http://localhost:8006/productionStream', basic.auth.enabled='false',
    @map(type='json'))
define stream SweetProductionStream (name string, amount double);

@sink(type='log')
define stream LowProductionAlertStream (name string, amount double);

-- 将 SweetProductionStream 中的数据传递到 LowProducitonAlertStream

@info(name='query1')
from SweetProductionStream
select *
insert into LowProductionAlertStream;

然后尝试发送一个小事件:

curl -X POST -d "{\"event\": {\"name\":\"sugar\",\"amount\": 20.5}}"  http://localhost
:8006/productionStream --header "Content-Type:application/json"

这将起作用。然后发送一个长事件(超过 1024 个字符)

curl -X POST -d "{\"event\": {\"name\":\"sugarlongggggggggggggggggg....gggggg\",\"amount\": 20.5}}"  http://localhost
:8006/productionStream --header "Content-Type:application/json"

在日志中您可以看到:

ERROR {org.wso2.extension.siddhi.map.json.sourcemapper.JsonSourceMapper} - Invalid Json String :{"event": {"name":"sugarlonggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
26/3/2019 20:38:15[2019-03-26 19:38:15,789] ERROR {org.wso2.extension.siddhi.map.json.sourcemapper.JsonSourceMapper} - Invalid Json String :gggggggggggggggggggggggggggggggggggggggggggggggggggggggg","amount": 20.5}}
26/3/2019 20:38:15[2019-03-26 19:38:15,791] ERROR {org.wso2.transport.http.netty.common.Util} - Remote client closed the connection before completing outbound response io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: cannot send more responses than requests
26/3/2019 20:38:15  at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:106)
26/3/2019 20:38:15  at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723)
26/3/2019 20:38:15  at io.netty.handler.stream.ChunkedWriteHandler.doFlush(ChunkedWriteHandler.java:304)
26/3/2019 20:38:15  at io.netty.handler.stream.ChunkedWriteHandler.flush(ChunkedWriteHandler.java:137)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749)
26/3/2019 20:38:15  at io.netty.channel.ChannelDuplexHandler.flush(ChannelDuplexHandler.java:117)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:802)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:814)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:794)
26/3/2019 20:38:15  at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:831)
26/3/2019 20:38:15  at org.wso2.transport.http.netty.contractimpl.HttpOutboundRespListener.writeOutboundResponseHeaderAndBody(HttpOutboundRespListener.java:186)
26/3/2019 20:38:15  at org.wso2.transport.http.netty.contractimpl.HttpOutboundRespListener.writeOutboundResponse(HttpOutboundRespListener.java:138)
26/3/2019 20:38:15  at org.wso2.transport.http.netty.contractimpl.HttpOutboundRespListener.lambda$null$35(HttpOutboundRespListener.java:94)
26/3/2019 20:38:15  at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
26/3/2019 20:38:15  at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
26/3/2019 20:38:15  at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
26/3/2019 20:38:15  at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
26/3/2019 20:38:15  at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
26/3/2019 20:38:15  at java.lang.Thread.run(Thread.java:748)
26/3/2019 20:38:15Caused by: java.lang.IllegalStateException: cannot send more responses than requests
26/3/2019 20:38:15  at io.netty.handler.codec.http.HttpContentEncoder.encode(HttpContentEncoder.java:110)
26/3/2019 20:38:15  at io.netty.handler.codec.http.HttpContentEncoder.encode(HttpContentEncoder.java:51)
26/3/2019 20:38:15  at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67)
26/3/2019 20:38:15  at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:88)
26/3/2019 20:38:15  ... 25 more
4

2 回答 2

3

这是一个已知问题,已从 siddhi-io-http-1.0.40 修复。

为了在您的流处理器包上应用最新版本,请按照以下步骤操作,

  1. 从以下链接下载 siddhi-io-http-1.0.40.jar。 https://store.wso2.com/store/assets/analyticsextension/details/63a5db75-586e-48d0-8244-4c16774e8846
  2. 将 /lib 目录中的现有 siddhi-io-http-1.0.39.jar 替换为最新的 siddhi-io-http-1.0.40.jar。
于 2019-03-27T06:12:50.343 回答
2

此问题已被确定 [1] 并在最新版本中得到修复。为了将最新版本应用到 SP,请按照以下步骤操作。

  1. 从WSO2 扩展商店[2]下载新版本的 siddhi-io-http 扩展。
  2. 将 SP-HOME/lib 目录中现有的 siddhi-io-http-xxxjar 替换为上面下载的。
  3. 重新启动服务器。

[1] https://github.com/wso2-extensions/siddhi-io-http/issues/84

[2] https://store.wso2.com/store/assets/analyticsextension/details/63a5db75-586e-48d0-8244-4c16774e8846

于 2019-03-27T06:24:13.293 回答