BewareMyPower commented on issue #18395:
URL: https://github.com/apache/pulsar/issues/18395#issuecomment-1309864662

   I can reproduce this issue by the following steps.
   
   Run a 2.10.1 consumer:
   
   ```java
           @Cleanup final var client = 
PulsarClient.builder().serviceUrl(Config.BROKER_URL).build();
           @Cleanup final var consumer = client.newConsumer()
                   .topic("message-id-topic")
                   .subscriptionName("sub")
                   
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
                   .subscribe();
           while (true) {
               final var msg = consumer.receive();
               try {
                   final var id = 
MessageId.fromByteArrayWithTopic(msg.getData(),
                           consumer.getTopic());
                   log.info("XYZ Received {}", id);
               } catch (IOException e) {
                   log.error("XYZ Failed to parse: {}", e.getMessage());
               }
           }
   ```
   
   Run a 2.7.1 producer:
   
   ```java
           @Cleanup final var client = PulsarClient.builder()
                   .serviceUrl("pulsar://172.20.58.232:6650")
                   .build();
           @Cleanup final var producer = client.newProducer(Schema.STRING)
                   .topic("topic")
                   .create();
           var id = producer.send("msg");
           log.info("XYZ sent to {}", id);
           @Cleanup final var msgIdProducer = client.newProducer()
                   .topic("message-id-topic")
                   .create();
           msgIdProducer.send(id.toByteArray());
   ```
   
   The consumer side failed with
   
   ```
   Exception in thread "main" java.lang.IllegalStateException: Field 
'batch_size' is not set
        at 
org.apache.pulsar.common.api.proto.MessageIdData.getBatchSize(MessageIdData.java:147)
        at 
org.apache.pulsar.client.impl.MessageIdImpl.fromByteArrayWithTopic(MessageIdImpl.java:159)
        at 
org.apache.pulsar.client.impl.MessageIdImpl.fromByteArrayWithTopic(MessageIdImpl.java:144)
        at 
org.apache.pulsar.client.impl.PulsarClientImplementationBindingImpl.newMessageIdFromByteArrayWithTopic(PulsarClientImplementationBindingImpl.java:110)
        at 
org.apache.pulsar.client.api.MessageId.fromByteArrayWithTopic(MessageId.java:73)
        at pulsar.ConsumerDemo.main(ConsumerDemo.java:27)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to