简体   繁体   English

是否可以延迟在netty的socket.io实现中发送确认消息?

[英]Is it possible to delay sending an ack in netty's socket.io implementation?

While using https://github.com/mrniko/netty-socketio I'm using a queue and a thread pool to process the received data (sorry about the formatting stackoverflow is complaining about spaces when I put the code on different lines): 在使用https://github.com/mrniko/netty-socketio时,我正在使用队列和线程池来处理接收到的数据(对格式栈溢出感到抱歉,当我将代码放在不同的行上时会抱怨空格):

server.addEventListener("NEW_SELL_ORDER", SellOrder.class, (client, data, ackSender) -> actionQueue.add((connection) -> this.onNewSellOrder(connection, client, data, ackSender)));

The problem is that ackSender isn't usable anymore because the threadpool is processing the request a split second later. 问题在于, ackSender不再可用,因为ackSender会处理请求。

Resulting in the question: is it possible to delay sending an ack in netty's socket.io implementation? 产生的问题是:是否可以延迟在netty的socket.io实现中发送确认消息?

See: https://github.com/mrniko/netty-socketio/blob/master/src/main/java/com/corundumstudio/socketio/AckRequest.java 参见: https : //github.com/mrniko/netty-socketio/blob/master/src/main/java/com/corundumstudio/socketio/AckRequest.java

Yes it possible to handle ack sending manually. 是的,可以手动处理确认发送。

  1. You should switch ack mode to manual in configuration. 您应在配置中将确认模式切换为手动。

    config.setAckMode(AckMode.MANUAL)

  2. Send ack by yourself: 自己发送确认:

     server.addEventListener("NEW_SELL_ORDER", SellOrder.class, (client, data, ackSender) -> { if (ackRequest.isAckRequested()) { ackRequest.sendAckData(...); } }); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM