Search in sources :

Example 1 with CommandMessage

use of org.apache.pulsar.common.api.proto.CommandMessage in project pulsar by apache.

the class Commands method newMessageCommand.

public static BaseCommand newMessageCommand(long consumerId, long ledgerId, long entryId, int partition, int redeliveryCount, long[] ackSet, long consumerEpoch) {
    BaseCommand cmd = localCmd(Type.MESSAGE);
    CommandMessage msg = cmd.setMessage().setConsumerId(consumerId);
    msg.setMessageId().setLedgerId(ledgerId).setEntryId(entryId).setPartition(partition);
    // consumerEpoch > -1 is useful
    if (consumerEpoch > DEFAULT_CONSUMER_EPOCH) {
        msg.setConsumerEpoch(consumerEpoch);
    }
    if (redeliveryCount > 0) {
        msg.setRedeliveryCount(redeliveryCount);
    }
    if (ackSet != null) {
        for (int i = 0; i < ackSet.length; i++) {
            msg.addAckSet(ackSet[i]);
        }
    }
    return cmd;
}
Also used : BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand) CommandMessage(org.apache.pulsar.common.api.proto.CommandMessage)

Aggregations

BaseCommand (org.apache.pulsar.common.api.proto.BaseCommand)1 CommandMessage (org.apache.pulsar.common.api.proto.CommandMessage)1