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;
}
Aggregations