Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Producer can't produce messages with an old schema version. #4737

Closed
codelipenghui opened this issue Jul 16, 2019 · 3 comments
Closed

Producer can't produce messages with an old schema version. #4737

codelipenghui opened this issue Jul 16, 2019 · 3 comments
Assignees
Labels
type/bug The PR fixed a bug or issue reported a bug
Milestone

Comments

@codelipenghui
Copy link
Contributor

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

@codelipenghui codelipenghui added the type/bug The PR fixed a bug or issue reported a bug label Jul 16, 2019
@codelipenghui codelipenghui self-assigned this Jul 16, 2019
@codelipenghui codelipenghui added this to the 2.4.1 milestone Jul 16, 2019
@codelipenghui
Copy link
Contributor Author

@congbobo184 please take a look this issue.

@jiazhai jiazhai modified the milestones: 2.4.1, 2.5.0 Aug 22, 2019
@jiazhai
Copy link
Member

jiazhai commented Aug 22, 2019

would like to move this to 2.5.0

@sijie
Copy link
Member

sijie commented Nov 25, 2019

This has been addressed by #5227

@sijie sijie closed this as completed Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

No branches or pull requests

3 participants