Describe the bug
Producer can't produce messages with an old schema version.
To Reproduce
Steps to reproduce the behavior:
- Use pulsar-admin to set-schema-autoupdate-strategy -c Backward public/default
- 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.
Describe the bug
Producer can't produce messages with an old schema version.
To Reproduce
Steps to reproduce the behavior:
Will produce the following error:
Expected behavior
At producer side, producer can send messages using an old version schema.