BewareMyPower opened a new issue #7728:
URL: https://github.com/apache/pulsar/issues/7728


   I have encountered schema problems recently. eg, creating a consumer with 
`Schema.STRING`:
   
   ```java
           try (PulsarClient client = PulsarClient.builder() //
                   .serviceUrl("pulsar://localhost:6650") //
                   .build()) {
               try (Consumer<String> consumer = 
client.newConsumer(Schema.STRING) //
                       .topic("Foo") //
                       .subscriptionName("test-sub") //
                       
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest) //
                       .subscribe()) {
                   log.info("Subscribe successfully");
               }
           } catch (PulsarClientException e) {
               log.error("{}", e.getMessage(), e);
           }
   ```
   
   The log is:
   
   > 
org.apache.pulsar.client.api.PulsarClientException$IncompatibleSchemaException: 
Topic does not have schema to check
   
   Finally I found some topics may not have associated schema, see 
`SchemaRegistryServiceImpl` in `broker.service.schema` package:
   
   ```java
       public CompletableFuture<Void> checkConsumerCompatibility(String 
schemaId, SchemaData schemaData,
                                                                 
SchemaCompatibilityStrategy strategy) {
           return getSchema(schemaId).thenCompose(existingSchema -> {
               if (existingSchema != null && 
!existingSchema.schema.isDeleted()) {
                   // ...
               } else {  // existingSchema is null or it's deleted
                   return FutureUtil.failedFuture(new 
IncompatibleSchemaException("Topic does not have schema to check"));
               }
           });
       }
   ```
   
    I thought it's because those topics have been produced by C++ client 
without schema. But it seems that I'm wrong. I created a new topic and used C++ 
client to produce some messages, but a consumer with string schema subscribed 
successfully. I've also trying producing some messages with Java producer 
without schema, but the result were the same.
   
   In my private cluster for test, there're still 2 topics that couldn't be 
subscribed with string schema. But I didn't know how did I make it happen.


----------------------------------------------------------------
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.

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


Reply via email to