You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/07/16 09:46:34 UTC

[GitHub] [pulsar] codelipenghui opened a new issue #4737: Producer can't produce messages with an old schema version.

codelipenghui opened a new issue #4737: Producer can't produce messages with an old schema version.
URL: https://github.com/apache/pulsar/issues/4737
 
 
   **Describe the bug**
   
   Producer can't produce messages with an old schema version.
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. Use pulsar-admin to set-schema-autoupdate-strategy -c Backward public/default
   2. Run following test case:
   ```java
   
   import org.apache.pulsar.client.api.PulsarClient;
   import org.apache.pulsar.client.api.PulsarClientException;
   import org.apache.pulsar.client.api.Schema;
   
   public class SchemaTests {
   
       public static void main(String[] args) throws PulsarClientException {
   
           PulsarClient client = PulsarClient.builder().serviceUrl("pulsar://127.0.0.1:6650").build();
           client.newProducer(Schema.AVRO(UserV1.class)).topic("topic-1").create();
           client.newProducer(Schema.AVRO(UserV2.class)).topic("topic-1").create();
           client.newProducer(Schema.AVRO(UserV1.class)).topic("topic-1").create();
   
       }
   
   
       private static class UserV1 {
   
           private String username;
           private int age;
   
           public String getUsername() {
               return username;
           }
   
           public void setUsername(String username) {
               this.username = username;
           }
   
           public int getAge() {
               return age;
           }
   
           public void setAge(int age) {
               this.age = age;
           }
       }
   
       private static class UserV2 {
   
           public String getUsername() {
               return username;
           }
   
           public void setUsername(String username) {
               this.username = username;
           }
   
           private String username;
   
       }
   
   }
   ```
   
   Will produce the following error:
   
   ```
   Exception in thread "main" org.apache.pulsar.client.api.PulsarClientException$IncompatibleSchemaException: org.apache.pulsar.broker.service.schema.exceptions.IncompatibleSchemaException: Incompatible schema used
   	at org.apache.pulsar.client.api.PulsarClientException.unwrap(PulsarClientException.java:253)
   	at org.apache.pulsar.client.impl.ProducerBuilderImpl.create(ProducerBuilderImpl.java:88)
   	at org.apache.pulsar.issue.SchemaTests.main(SchemaTests.java:12)
   ```
   
   **Expected behavior**
   
   At producer side, producer can send messages using an old version schema.
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services