maskit commented on a change in pull request #2829: Fix Websocket Consume Messages in Partitioned Topics URL: https://github.com/apache/pulsar/pull/2829#discussion_r228456096
########## File path: pulsar-client/src/main/java/org/apache/pulsar/client/impl/MessageIdImpl.java ########## @@ -113,6 +114,36 @@ public static MessageId fromByteArray(byte[] data) throws IOException { return messageId; } + public static MessageId fromByteArrayWithTopic(byte[] data, TopicName topicName) throws IOException { + checkNotNull(data); + ByteBufCodedInputStream inputStream = ByteBufCodedInputStream.get(Unpooled.wrappedBuffer(data, 0, data.length)); + PulsarApi.MessageIdData.Builder builder = PulsarApi.MessageIdData.newBuilder(); + + PulsarApi.MessageIdData idData; + try { + idData = builder.mergeFrom(inputStream, null).build(); + } catch (UninitializedMessageException e) { + throw new IOException(e); + } + + MessageId messageId; + if (idData.hasBatchIndex()) { + messageId = new BatchMessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition(), + idData.getBatchIndex()); + } else { + messageId = new MessageIdImpl(idData.getLedgerId(), idData.getEntryId(), idData.getPartition()); + } + if (idData.getPartition() > -1 && topicName != null) { Review comment: Oh, we need to pass it to the constructor... sounds odd though. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services