Create topic inline with trigger similar to subscribers
Hi everyone, I have a question related to how to use topics. Seems like if I want to trigger an event and add a topic key that doesn't exist, then it errors out.
What do you do for the use case where you don't know if there is a topic key ahead of the time?
I could call the get topic by key endpoint but that seems too much work everytime I want to trigger an event.
For example, I have some products that are out of stock and just now is back in stock. I would like to notify anyone who subscribes to the product back in stock event. But I won't know if anyone has subscribed before. So if my service generates a topic key "back-in-stock-product-id-1234", and that topic doesn't exist because no one has subscribed to it in a separate UI, then the trigger call fails.
For another more complex case, I would like to notify anyone who subscirbes to back in stock notification for the product level but also store level. Ideally my service would generate 2 topic keys "back-in-stock-product-id-1234" and "back-in-stock-store-345", and then trigger the event. But like this case, as there are more and more types of topics, my service has to call the API endpoint to check if topic exist for every key, which seems like not performant.
by @yellowbird_33747
Original Message Link
What do you do for the use case where you don't know if there is a topic key ahead of the time?
I could call the get topic by key endpoint but that seems too much work everytime I want to trigger an event.
For example, I have some products that are out of stock and just now is back in stock. I would like to notify anyone who subscribes to the product back in stock event. But I won't know if anyone has subscribed before. So if my service generates a topic key "back-in-stock-product-id-1234", and that topic doesn't exist because no one has subscribed to it in a separate UI, then the trigger call fails.
For another more complex case, I would like to notify anyone who subscirbes to back in stock notification for the product level but also store level. Ideally my service would generate 2 topic keys "back-in-stock-product-id-1234" and "back-in-stock-store-345", and then trigger the event. But like this case, as there are more and more types of topics, my service has to call the API endpoint to check if topic exist for every key, which seems like not performant.
by @yellowbird_33747
Original Message Link