Search in sources :

Example 6 with MessageIdData

use of com.yahoo.pulsar.common.api.proto.PulsarApi.MessageIdData in project pulsar by yahoo.

the class Consumer method messageAcked.

void messageAcked(CommandAck ack) {
    MessageIdData msgId = ack.getMessageId();
    PositionImpl position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId());
    if (ack.hasValidationError()) {
        log.error("[{}] [{}] Received ack for corrupted message at {} - Reason: {}", subscription, consumerId, position, ack.getValidationError());
    }
    if (subType == SubType.Shared) {
        // On shared subscriptions, cumulative ack is not supported
        checkArgument(ack.getAckType() == AckType.Individual);
        // Only ack a single message
        removePendingAcks(position);
        subscription.acknowledgeMessage(position, AckType.Individual);
    } else {
        subscription.acknowledgeMessage(position, ack.getAckType());
    }
}
Also used : MessageIdData(com.yahoo.pulsar.common.api.proto.PulsarApi.MessageIdData) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl)

Example 7 with MessageIdData

use of com.yahoo.pulsar.common.api.proto.PulsarApi.MessageIdData in project pulsar by yahoo.

the class Commands method newSendReceipt.

public static ByteBuf newSendReceipt(long producerId, long sequenceId, long ledgerId, long entryId) {
    CommandSendReceipt.Builder sendReceiptBuilder = CommandSendReceipt.newBuilder();
    sendReceiptBuilder.setProducerId(producerId);
    sendReceiptBuilder.setSequenceId(sequenceId);
    MessageIdData.Builder messageIdBuilder = MessageIdData.newBuilder();
    messageIdBuilder.setLedgerId(ledgerId);
    messageIdBuilder.setEntryId(entryId);
    MessageIdData messageId = messageIdBuilder.build();
    sendReceiptBuilder.setMessageId(messageId);
    CommandSendReceipt sendReceipt = sendReceiptBuilder.build();
    ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.SEND_RECEIPT).setSendReceipt(sendReceipt));
    messageIdBuilder.recycle();
    messageId.recycle();
    sendReceiptBuilder.recycle();
    sendReceipt.recycle();
    return res;
}
Also used : MessageIdData(com.yahoo.pulsar.common.api.proto.PulsarApi.MessageIdData) CommandSendReceipt(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandSendReceipt) UnpooledHeapByteBuf(io.netty.buffer.UnpooledHeapByteBuf) RecyclableDuplicateByteBuf(io.netty.buffer.RecyclableDuplicateByteBuf) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

MessageIdData (com.yahoo.pulsar.common.api.proto.PulsarApi.MessageIdData)7 ByteBuf (io.netty.buffer.ByteBuf)5 PositionImpl (org.apache.bookkeeper.mledger.impl.PositionImpl)3 RecyclableDuplicateByteBuf (io.netty.buffer.RecyclableDuplicateByteBuf)2 UnpooledHeapByteBuf (io.netty.buffer.UnpooledHeapByteBuf)2 IOException (java.io.IOException)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Iterables (com.google.common.collect.Iterables)1 PulsarServerException (com.yahoo.pulsar.broker.PulsarServerException)1 Crc32cChecksum.computeChecksum (com.yahoo.pulsar.checksum.utils.Crc32cChecksum.computeChecksum)1 Consumer (com.yahoo.pulsar.client.api.Consumer)1 ConsumerConfiguration (com.yahoo.pulsar.client.api.ConsumerConfiguration)1 Message (com.yahoo.pulsar.client.api.Message)1 MessageId (com.yahoo.pulsar.client.api.MessageId)1 PulsarClientException (com.yahoo.pulsar.client.api.PulsarClientException)1 SubscriptionType (com.yahoo.pulsar.client.api.SubscriptionType)1 FutureUtil (com.yahoo.pulsar.client.util.FutureUtil)1 Commands (com.yahoo.pulsar.common.api.Commands)1 Commands.hasChecksum (com.yahoo.pulsar.common.api.Commands.hasChecksum)1