生产者的Exclusive和Shared运行效果是这样的吗?

@Bean("shared_Producer1_myTopic1")
public Producer createShared_Producer1_myTopic1() throws PulsarClientException {
    Producer<String> stringProducer = pulsarClient.newProducer(Schema.STRING)
            .topic(myTopic1)
            .accessMode(ProducerAccessMode.Shared)
            .create();
    return stringProducer;
}

@Bean("shared_Producer2_myTopic1")
public Producer createShared_Producer2_myTopic1() throws PulsarClientException {
    Producer<String> stringProducer = pulsarClient.newProducer(Schema.STRING)
            .topic(myTopic1)
            .accessMode(ProducerAccessMode.Shared)
            .create();
    return stringProducer;
}

以上启动时不报错,并且可以正常生产。

@Bean("exclusive_Producer1_myTopic2")
public Producer createExclusive_Producer1_myTopic2() throws PulsarClientException {
    Producer<String> stringProducer = pulsarClient.newProducer(Schema.STRING)
            .topic(myTopic2)
            .accessMode(ProducerAccessMode.Exclusive)
            .create();
    return stringProducer;
}

@Bean("exclusive_Producer2_myTopic2")
public Producer createExclusive_Producer2_myTopic2() throws PulsarClientException {
    Producer<String> stringProducer = pulsarClient.newProducer(Schema.STRING)
            .topic(myTopic2)
            .accessMode(ProducerAccessMode.Exclusive)
            .create();
    return stringProducer;
}

以上代码启动报错,异常信息如下:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.pulsar.client.api.Producer]: Factory method ‘createExclusive_Producer2_myTopic2’ threw exception; nested exception is org.apache.pulsar.client.api.PulsarClientException$ProducerFencedException: {“errorMsg”:“org.apache.pulsar.broker.service.BrokerServiceException$ProducerFencedException: Topic has an existing exclusive producer: standalone-15-19”,“reqId”:3843203914690722556, “remote”:“/192.168.3.84:6650”, “local”:“/192.168.3.188:52187”}

我不知道我写的DEMO这两种跑起来的结果是不是正常的,就是这样的,因为官方文档对这个属性只有解释,没有相关的DEMO代码,我在:

也没有找到相关的CODE

感谢。

Shared 可以创建多个所以不会报错, Exclusive 只允许一个所以会报这个错误。