Handle binder config in BindingProperties

- Per-binding properties defined in `BindingProperties` need to hold the binder specific configurations needed when binding producer/consumers.
Previously, these were added in `ChannelBindingServiceProperties` as producer/consumer properties. Since these configuration properties are for
per-binding based on the input/output (consumer/producer) channel being bound it is better to move these properties into `BindingProperties`.
 - Add some of the supported producer/consumer properties into BindingProperties

- This fixes #256

Rename CommonBinderProperties -> BinderPropertyKeys

Rename class AbstractBinderPropertiesAccessor.java -> AbstractBindingPropertiesAccessor.java
This commit is contained in:
Ilayaperumal Gopinathan
2015-12-22 22:41:28 +05:30
committed by Mark Fisher
parent 373dd12fbb
commit fa89e5bcb6
22 changed files with 408 additions and 256 deletions

View File

@@ -23,9 +23,9 @@ import java.util.Properties;
import java.util.Set;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.cloud.stream.binder.AbstractBinderPropertiesAccessor;
import org.springframework.cloud.stream.binder.AbstractBindingPropertiesAccessor;
import org.springframework.cloud.stream.binder.BinderHeaders;
import org.springframework.cloud.stream.binder.BinderProperties;
import org.springframework.cloud.stream.binder.BinderPropertyKeys;
import org.springframework.cloud.stream.binder.Binding;
import org.springframework.cloud.stream.binder.EmbeddedHeadersMessageConverter;
import org.springframework.cloud.stream.binder.MessageChannelBinderSupport;
@@ -83,7 +83,7 @@ public class RedisMessageChannelBinder extends MessageChannelBinderSupport imple
private static final Set<Object> SUPPORTED_NAMED_CONSUMER_PROPERTIES = new SetBuilder()
.addAll(CONSUMER_STANDARD_PROPERTIES)
.addAll(CONSUMER_RETRY_PROPERTIES)
.add(BinderProperties.CONCURRENCY)
.add(BinderPropertyKeys.CONCURRENCY)
.build();
/**
@@ -91,7 +91,7 @@ public class RedisMessageChannelBinder extends MessageChannelBinderSupport imple
*/
private static final Set<Object> SUPPORTED_CONSUMER_PROPERTIES = new SetBuilder()
.addAll(SUPPORTED_NAMED_CONSUMER_PROPERTIES)
.add(BinderProperties.PARTITION_INDEX)
.add(BinderPropertyKeys.PARTITION_INDEX)
.build();
/**
@@ -101,7 +101,7 @@ public class RedisMessageChannelBinder extends MessageChannelBinderSupport imple
// request
.addAll(CONSUMER_STANDARD_PROPERTIES)
.addAll(CONSUMER_RETRY_PROPERTIES)
.add(BinderProperties.CONCURRENCY)
.add(BinderPropertyKeys.CONCURRENCY)
.build();
/**
@@ -120,7 +120,7 @@ public class RedisMessageChannelBinder extends MessageChannelBinderSupport imple
private static final Set<Object> SUPPORTED_PRODUCER_PROPERTIES = new SetBuilder()
.addAll(PRODUCER_PARTITIONING_PROPERTIES)
.addAll(PRODUCER_STANDARD_PROPERTIES)
.add(BinderProperties.DIRECT_BINDING_ALLOWED)
.add(BinderPropertyKeys.DIRECT_BINDING_ALLOWED)
.build();
/**
@@ -129,7 +129,7 @@ public class RedisMessageChannelBinder extends MessageChannelBinderSupport imple
private static final Set<Object> SUPPORTED_REQUESTING_PRODUCER_PROPERTIES = new SetBuilder()
// reply
.addAll(CONSUMER_RETRY_PROPERTIES)
.add(BinderProperties.CONCURRENCY)
.add(BinderPropertyKeys.CONCURRENCY)
.build();
private final RedisConnectionFactory connectionFactory;
@@ -466,7 +466,7 @@ public class RedisMessageChannelBinder extends MessageChannelBinderSupport imple
}
private static class RedisPropertiesAccessor extends AbstractBinderPropertiesAccessor {
private static class RedisPropertiesAccessor extends AbstractBindingPropertiesAccessor {
public RedisPropertiesAccessor(Properties properties) {
super(properties);

View File

@@ -39,7 +39,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.springframework.cloud.stream.binder.Binder;
import org.springframework.cloud.stream.binder.BinderProperties;
import org.springframework.cloud.stream.binder.BinderPropertyKeys;
import org.springframework.cloud.stream.binder.Binding;
import org.springframework.cloud.stream.binder.EmbeddedHeadersMessageConverter;
import org.springframework.cloud.stream.binder.PartitionCapableBinderTests;
@@ -171,7 +171,7 @@ public class RedisBinderTests extends PartitionCapableBinderTests {
properties.put("partitionKeyExtractorClass", "foo");
properties.put("partitionSelectorExpression", "0");
properties.put("partitionSelectorClass", "foo");
properties.put(BinderProperties.NEXT_MODULE_COUNT, "1");
properties.put(BinderPropertyKeys.NEXT_MODULE_COUNT, "1");
binder.bindProducer("props.0", new DirectChannel(), properties);
assertEquals(1, bindings.size());
@@ -287,7 +287,7 @@ public class RedisBinderTests extends PartitionCapableBinderTests {
properties.put("partitionKeyExtractorClass", "foo");
properties.put("partitionSelectorExpression", "0");
properties.put("partitionSelectorClass", "foo");
properties.put(BinderProperties.NEXT_MODULE_COUNT, "1");
properties.put(BinderPropertyKeys.NEXT_MODULE_COUNT, "1");
properties.put("partitionIndex", "0");
try {
binder.bindReplier("dummy", new DirectChannel(), new DirectChannel(), properties);