Is it possible to have multiple producers for the same topic on Pulsar?

匆匆过客 提交于 2021-01-29 12:36:42

问题


I know you can set topic subscription to be shared subscription to allow for multiple Consumers on the same topic. Can this also be done for multiple Producers?

For some reason when I try to, I get a Producer with name '<topic_name>' is already connected to topic


回答1:


Yes, you can have multiple producers on a topic. You just have to make sure each producer has a unique name. From the ProducerBuilder.producerName section of the Java client API docs:

When specifying a name, it is up to the user to ensure that, for a given topic, the producer name is unique across all Pulsar's clusters. Brokers will enforce that only a single producer a given name can be publishing on a topic.

The easiest way to ensure the producer name is unique is to let Pulsar set it automatically for you. From the same section:

If not assigned, the system will generate a globally unique name which can be accessed with Producer.getProducerName().



来源:https://stackoverflow.com/questions/63258912/is-it-possible-to-have-multiple-producers-for-the-same-topic-on-pulsar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!