Set default binding group name to "sleuth"

Can be changed by user with spring.sleuth.stream.group.

Fixes gh-134
This commit is contained in:
Dave Syer
2016-01-28 17:26:39 +00:00
parent 35f1b0c496
commit e2419d8cc0
2 changed files with 8 additions and 1 deletions

View File

@@ -27,4 +27,5 @@ import lombok.Data;
@Data
public class SleuthStreamProperties {
private boolean enabled = true;
private String group = SleuthSink.INPUT;
}

View File

@@ -52,7 +52,8 @@ public class StreamEnvironmentPostProcessor implements EnvironmentPostProcessor
SpringApplication application) {
Map<String, Object> map = new HashMap<String, Object>();
ResourceLoader resourceLoader = application.getResourceLoader();
resourceLoader = resourceLoader==null ? new DefaultResourceLoader() : resourceLoader;
resourceLoader = resourceLoader == null ? new DefaultResourceLoader()
: resourceLoader;
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(
resourceLoader);
try {
@@ -66,6 +67,11 @@ public class StreamEnvironmentPostProcessor implements EnvironmentPostProcessor
catch (IOException e) {
throw new IllegalStateException("Cannot load META-INF/spring.binders", e);
}
// Technically this is only needed on the consumer, but it's fine to be explicit
// on producers as well. It puts all consumers in the same "group", meaning they
// compete with each other and only one gets each message.
map.put("spring.cloud.stream.bindings." + SleuthSink.INPUT + ".group",
environment.getProperty("spring.sleuth.stream.group", SleuthSink.INPUT));
addOrReplace(environment.getPropertySources(), map);
}