I'm trying to send and receive messages to channels/topics whose destination names are in a database, so they can be added/modified/deleted at runtime, but I'm surprised I have found little on the web. I'm using Spring Cloud Streams to allow to change the underlying broker.
To send messages to dynamically bound destinations I'm going with BinderAwareChannelResolver.resolveDestination(target).send(message)
, but I haven't found something that works like it to receive messages.
My questions are:
1. Is there something similar?
2. how can the message be processed periodically as @StreamListener
does?
3. And not as important, but can you create a subscriber automatically in case there is none?
Thanks for any help!

- 2,642
- 7
- 40
- 62
1 Answers
This is a bit out of scope of the original design of the framework. But I would further question your architecture. . . If you truly desire to subscribe to unlimited amount of destinations I wonder why? What is the underlying business requirement?
Keep in mind that even if we were to do it somehow that would require creation of a message listener container dynamically for each new destination which would raise more questions, such as, how long would such container have to live since eventually you would run out of resources.
If, however, you simply asking about possibility of mapping multiple destinations to a single channel so all messages go to the same message handler (e.g., StreamListener), then you can simply use input destination
property and define multiple destination delimited by comas.

- 5,820
- 16
- 17
-
The architecture has been imposed. For now, there are 2 clients. Messages are to be sent by service X to a queue that it's assigned exclusively for a client, so if a new client comes in, a different channel should be created, and now messages for that client should go to its new channel. A single service Y processes those messages based on the channel they come from, and sends new ones to different channels (also determined at runtime as new services can be added at any point). Since Y processes messages based on where they come from, I guess I would have to add data to the message send by X – CCC Mar 18 '19 at 18:41
-
I meant "service X to a channel".. Also what do you think about sending messages to dynamically bound channels using BinderAwareChannelResolver.resolveDestination(target).send(message)? – CCC Mar 18 '19 at 19:25
-
BTW, I found https://github.com/spring-cloud/spring-cloud-stream/issues/746 – CCC Mar 18 '19 at 20:27