spring-cloud / spring-cloud-config

External configuration (server and client) for Spring Cloud
Apache License 2.0
1.95k stars 1.29k forks source link

Dynamically set RoutingKey={application} as an option #1009

Open gustavo-armenta opened 6 years ago

gustavo-armenta commented 6 years ago

Question or Enhancement

I deployed ConfigServer as a PCF webapp

I am using one instance of ConfigServer to handle configuration changes for many applications (multitenant). The message written to SpringCloudBus has RoutingKey=”springCloudBus” and Payload contains “destinationService”:”{application}:**”. My problem is the message is received by clients from all applications and every app has to add code to filter by destinationService. I want the message to be received only by the {application} clients and it can be accomplished by setting RoutingKey={application}. Is there any way to do it today? Is it in the backlog?

spencergibb commented 6 years ago

Every spring bus client already has code to filter by destination service. Why do you need to add code?

gustavo-armenta commented 6 years ago

My application is in dotnet core. Steeltoe does not provide the SpringCloudBus client

spencergibb commented 6 years ago

Ack. :+1:

spencergibb commented 5 years ago

@olegz or @sobychacko I think the question here is: is there a way to dynamically set the RoutingKey using spring cloud stream abstractions?

olegz commented 5 years ago

@spencergibb I think routingKeyExpression producer property is what you're looking for.

A SpEL expression to determine the routing key to use when publishing messages. For a fixed routing key, use a literal expression, such as routingKeyExpression='my.routingKey' in a properties file or routingKeyExpression: '''my.routingKey''' in a YAML file.

https://cloud.spring.io/spring-cloud-stream-binder-rabbit/spring-cloud-stream-binder-rabbit.html#_rabbit_producer_properties

spencergibb commented 5 years ago

Interesting. What object is available as context for the expression? OP wants something dynamic.

olegz commented 5 years ago

It's extended Rabbit producer properties: spring.cloud.stream.rabbit.bindings.<channelName>.producer.routing-key-expression=blah