use of com.yahoo.pulsar.websocket.data.ConsumerAck in project pulsar by yahoo.
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);
int pending = pendingMessages.getAndDecrement();
if (pending >= maxPendingMessages) {
// Resume delivery
receiveMessage();
}
}
Aggregations