Skip to content

getLastMessageId from PulsarAdmin doesn't work with BatchMessageIdImpl #6462

@kevin-kosmos

Description

@kevin-kosmos

Describe the bug
A topic created with a producer in batch mode generates batch messages id : ledgerId:entryId:partitionIndex:batchIndex.
The getLastMessageId method return a MessageIdImpl which doesn't use the batchIndex parameter.

To Reproduce

  1. Send messages with a producer in batch mode :
    `

     public class ProducerTest {
    

    public static void main(String[] args) throws Exception {

     try (PulsarClient client = PulsarClient.builder()
     		.serviceUrl("pulsar://localhost:6650")
     		.build()) {
    
     	Producer<String> producer = client
     			.newProducer(Schema.STRING)
     			.topic("topic")
     			.enableBatching(true)
     			.batchingMaxMessages(10)
     			.blockIfQueueFull(false)
     			.batchingMaxPublishDelay(100, TimeUnit.SECONDS)
     			.create();
    
     	CompletableFuture<MessageId> messageIdCompletableFuture = null;
     	for (int i = 0; i < 10; i++) {
     		messageIdCompletableFuture = producer.newMessage()
     				.value(String.valueOf(i))
     				.sendAsync();
     	}
    
     	messageIdCompletableFuture.get();
     }
    

    }
    }`

  2. Shows generated messages :

|value|__topic |__messageId |__messageIdToString|
|0 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 00]|39792:0: -1:0 |
|1 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 01]|39792:0: -1:1 |
|2 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 02]|39792:0: -1:2 |
|3 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 03]|39792:0: -1:3 |
|4 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 04]|39792:0: -1:4 |
|5 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 05]|39792:0: -1:5 |
|6 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 06]|39792:0: -1:6 |
|7 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 07]|39792:0: -1:7 |
|8 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 08]|39792:0: -1:8 |
|9 |persistent://public/default/topic|[08 F0 B6 02 10 00 20 09]|39792:0: -1:9 |

  1. Retrieve the last message id from pulsar admin and display it :
    39792:0: -1

Expected behavior
It shoud return 39792:0: -1:9

Desktop (please complete the following information):

  • OS: Ubuntu 18.04
  • Pulsar runs in docker standalone instance

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugThe PR fixed a bug or issue reported a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions