🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
New Spring Cloud Stream Dynamic Topic Publish Sample!
Heads up for everyone using Spring Cloud Stream I created a new sample that shows how to publish to dynamic topics! I'll be creating a tutorial or blog at some point to add more explanation, but for now you can check out the code on github:
Note that this is already setup for v1.1.1 of solace-spring-cloud
which is currently waiting for mvn central to sync (It's taking waay longer than I expected!). If you have a compile error just change that to v1.1.0 while we wait.
Comments
-
That's pretty interesting. I think I can use this nicely with my https://github.com/solacese/topic-serialization project. It provides a reflection-based implementation of topic serialization via a template string like:
Stores/{state}/{storeNumber}/Order/{orderId}/{action}
I use it in Publishers to dynamically construct a topic string by passing in an object, and in Subscribers construct an intelligent subscription string based on a map of queries. Separates out the dynamic topic serialization just like we normally do with payload serialization; guessing it would look something like this (not a Spring guru)?
@Autowired TopicStrategy<Order> strategy; @Bean public Consumer<Order> functionUsingStreamBridge(StreamBridge streamBridge) { return order -> { String topic = strategy.makeTopic(order); log.info("Processing order: " + order); streamBridge.send(topic, order); }; }
0 -
Hi @kov,
Yep, seems like you can use this for your use case. I need to write a blog on this at some point, but depending on the level of performance you require you might consider using the target dest header option shown by functionUsingTargetDestHeader instead as with that option the dynamic part is then essentially handled by the Solace binder instead of within Spring. This approach has less overhead by avoiding the creation of a spring integration channel, caching it, etc. for each publish. This does of course does have a few downsides such as not being supported by all cloud stream binders and also not having the Spring Channel available for monitoring/metrics
-Marc0