How to dynamically produce and consume topic data #18853
Replies: 6 comments
|
For example, first subscribe to topic:persistent://public/default/my-topic: |
|
When producing data, I want to dynamically send it to different topics. The topics may be in different namespaces and different tenants. |
|
Like mqtt, a producer can send data on any topic, and a consumer can subscribe to topics dynamically |
|
You can use |
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. |
|
The issue had no activity for 30 days, mark with Stale label. |
Uh oh!
There was an error while loading. Please reload this page.
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
All reactions