spring-cloud-stream

Is "spring.cloud.stream.dynamicDestinations" still a valid configuration option?


I'm using spring-cloud-stream 4.1.1 and trying to set the configuration option spring.cloud.stream.dynamicDestinations, but it doesn't seem to be having the desired effect (or I'm not understanding how it's supposed to be used).

I'm setting spring.cloud.stream.dynamicDestinations to my defined bindings and I can see the defined values in BindingServiceProperties, so I know it's being read correctly. In some test code I'm doing:

streamBridge.send("noSuchBinding", myMessage);

and expecting to get an error, but instead a noSuchBinding binding is being dynamically created.

The docs (https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream.html#_configuration_options) say:

spring.cloud.stream.dynamicDestinations

A list of destinations that can be bound dynamically (for example, in a dynamic routing scenario). If set, only listed destinations can be bound.

Default: empty (letting any destination be bound).

Looking at BindingServiceProperties, I don't see that the value of dynamicDestinations is being used anywhere to restrict the creation of dynamic bindings.

My overall application is using Kafka bindings. In our particular environment, I need to ensure only pre-defined topics are utilized; under no circumstance should a topic/binding be dynamically created.


Solution

  • Although dynamicDestinations is still present in the BindingServiceProperties, it is not used any longer. We will deprecate that property. https://github.com/spring-cloud/spring-cloud-stream/issues/2955

    The correct way to create dynamic bindings is via StreamBridge. You can restore the same behavior from dyamicDestinations by using output-bindings.

    https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream.html#explicit-binding-creation

    https://docs.spring.io/spring-cloud-stream/docs/current/reference/html/spring-cloud-stream.html#_sending_arbitrary_data_to_an_output_e_g_foreign_event_driven_sources