How to dynamically produce and consume topic data #18853
Replies: 6 comments
-
For example, first subscribe to topic:persistent://public/default/my-topic: |
Beta Was this translation helpful? Give feedback.
-
When producing data, I want to dynamically send it to different topics. The topics may be in different namespaces and different tenants. |
Beta Was this translation helpful? Give feedback.
-
Like mqtt, a producer can send data on any topic, and a consumer can subscribe to topics dynamically |
Beta Was this translation helpful? Give feedback.
-
You can use |
Beta Was this translation helpful? Give feedback.
-
In Pulsar client, you must create a separate producer for sending to a different topic. There are many ways to achieve what you are describing. The simplest approach is to create a producer, send the message and then close the producer. However, for most cases, this wouldn't be efficient, and producer caching is needed. Here is a code example in the Pulsar code base of producer caching: The problem with that solution is that the producers accumulate and don't get closed automatically. Closing idle producers can be achieved by using Caffeine cache as the "container". Caffeine's I hope this helps implementing your use case. |
Beta Was this translation helpful? Give feedback.
-
The issue had no activity for 30 days, mark with Stale label. |
Beta Was this translation helpful? Give feedback.
-
After creating a Producer, I want to send data to multiple different topics, or create a Consumer, I want to consume data from multiple topics
Beta Was this translation helpful? Give feedback.
All reactions