use of org.apache.pulsar.websocket.data.ConsumerAck in project incubator-pulsar by apache.
the class ConsumerHandler method onWebSocketText.
@Override
public void onWebSocketText(String message) {
super.onWebSocketText(message);
// We should have received an ack
MessageId msgId;
try {
ConsumerAck ack = ObjectMapperFactory.getThreadLocal().readValue(message, ConsumerAck.class);
msgId = MessageId.fromByteArray(Base64.getDecoder().decode(ack.messageId));
} catch (IOException e) {
log.warn("Failed to deserialize message id: {}", message, e);
close(WebSocketError.FailedToDeserializeFromJSON);
return;
}
consumer.acknowledgeAsync(msgId).thenAccept(consumer -> numMsgsAcked.increment());
int pending = pendingMessages.getAndDecrement();
if (pending >= maxPendingMessages) {
// Resume delivery
receiveMessage();
}
}
Aggregations