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?
Yes it possible to handle ack sending manually.
You should switch ack mode to manual in configuration.
config.setAckMode(AckMode.MANUAL)
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.