Search in sources :

Example 1 with CommandAck

use of org.apache.pulsar.common.api.proto.PulsarApi.CommandAck in project incubator-pulsar by apache.

the class Commands method newAck.

public static ByteBuf newAck(long consumerId, long ledgerId, long entryId, AckType ackType, ValidationError validationError, Map<String, Long> properties) {
    CommandAck.Builder ackBuilder = CommandAck.newBuilder();
    ackBuilder.setConsumerId(consumerId);
    ackBuilder.setAckType(ackType);
    MessageIdData.Builder messageIdDataBuilder = MessageIdData.newBuilder();
    messageIdDataBuilder.setLedgerId(ledgerId);
    messageIdDataBuilder.setEntryId(entryId);
    MessageIdData messageIdData = messageIdDataBuilder.build();
    ackBuilder.setMessageId(messageIdData);
    if (validationError != null) {
        ackBuilder.setValidationError(validationError);
    }
    for (Map.Entry<String, Long> e : properties.entrySet()) {
        ackBuilder.addProperties(PulsarApi.KeyLongValue.newBuilder().setKey(e.getKey()).setValue(e.getValue()).build());
    }
    CommandAck ack = ackBuilder.build();
    ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.ACK).setAck(ack));
    ack.recycle();
    ackBuilder.recycle();
    messageIdDataBuilder.recycle();
    messageIdData.recycle();
    return res;
}
Also used : CommandAck(org.apache.pulsar.common.api.proto.PulsarApi.CommandAck) MessageIdData(org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData) ByteString(com.google.protobuf.ByteString) ByteBuf(io.netty.buffer.ByteBuf) Map(java.util.Map)

Aggregations

ByteString (com.google.protobuf.ByteString)1 ByteBuf (io.netty.buffer.ByteBuf)1 Map (java.util.Map)1 CommandAck (org.apache.pulsar.common.api.proto.PulsarApi.CommandAck)1 MessageIdData (org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData)1