@Override protected void handleGetLastMessageId(CommandGetLastMessageId getLastMessageId) { checkArgument(state == State.Connected); CompletableFuture<Consumer> consumerFuture = consumers.get(getLastMessageId.getConsumerId()); if (consumerFuture != null && consumerFuture.isDone() && !consumerFuture.isCompletedExceptionally()) { Consumer consumer = consumerFuture.getNow(null); long requestId = getLastMessageId.getRequestId(); Topic topic = consumer.getSubscription().getTopic(); Position position = topic.getLastMessageId(); int partitionIndex = TopicName.getPartitionIndex(topic.getName()); if (log.isDebugEnabled()) { log.debug("[{}] [{}][{}] Get LastMessageId {} partitionIndex {}", remoteAddress, topic.getName(), consumer.getSubscription().getName(), position, partitionIndex); } MessageIdData messageId = MessageIdData.newBuilder() .setLedgerId(((PositionImpl)position).getLedgerId()) .setEntryId(((PositionImpl)position).getEntryId()) .setPartition(partitionIndex) .build(); ctx.writeAndFlush(Commands.newGetLastMessageIdResponse(requestId, messageId)); } else { ctx.writeAndFlush(Commands.newError(getLastMessageId.getRequestId(), ServerError.MetadataError, "Consumer not found")); } }
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.CommandGetLastMessageId other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.CommandGetLastMessageId.getDefaultInstance()) return this; if (other.hasConsumerId()) { setConsumerId(other.getConsumerId()); } if (other.hasRequestId()) { setRequestId(other.getRequestId()); } return this; }
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.CommandGetLastMessageId other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.CommandGetLastMessageId.getDefaultInstance()) return this; if (other.hasConsumerId()) { setConsumerId(other.getConsumerId()); } if (other.hasRequestId()) { setRequestId(other.getRequestId()); } return this; }