简体   繁体   中英

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):

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.

Resulting in the question: is it possible to delay sending an ack in netty's socket.io implementation?

See: 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(...); } }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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