use of org.springframework.cloud.stream.binder.ConsumerProperties in project spring-cloud-stream by spring-cloud.
the class BindingService method bindConsumer.
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> Collection<Binding<T>> bindConsumer(T input, String inputName) {
String bindingTarget = this.bindingServiceProperties.getBindingDestination(inputName);
String[] bindingTargets = StringUtils.commaDelimitedListToStringArray(bindingTarget);
Collection<Binding<T>> bindings = new ArrayList<>();
Binder<T, ConsumerProperties, ?> binder = (Binder<T, ConsumerProperties, ?>) getBinder(inputName, input.getClass());
ConsumerProperties consumerProperties = this.bindingServiceProperties.getConsumerProperties(inputName);
if (binder instanceof ExtendedPropertiesBinder) {
Object extension = ((ExtendedPropertiesBinder) binder).getExtendedConsumerProperties(inputName);
ExtendedConsumerProperties extendedConsumerProperties = new ExtendedConsumerProperties(extension);
BeanUtils.copyProperties(consumerProperties, extendedConsumerProperties);
consumerProperties = extendedConsumerProperties;
}
validate(consumerProperties);
for (String target : bindingTargets) {
Binding<T> binding;
if (input instanceof PollableSource) {
binding = doBindPollableConsumer(input, inputName, binder, consumerProperties, target);
} else {
binding = doBindConsumer(input, inputName, binder, consumerProperties, target);
}
bindings.add(binding);
}
bindings = Collections.unmodifiableCollection(bindings);
this.consumerBindings.put(inputName, new ArrayList<Binding<?>>(bindings));
return bindings;
}
use of org.springframework.cloud.stream.binder.ConsumerProperties in project spring-cloud-stream by spring-cloud.
the class PartitionedConsumerTest method testBindingPartitionedConsumer.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testBindingPartitionedConsumer() {
Binder binder = this.binderFactory.getBinder(null, MessageChannel.class);
ArgumentCaptor<ConsumerProperties> argumentCaptor = ArgumentCaptor.forClass(ConsumerProperties.class);
verify(binder).bindConsumer(eq("partIn"), isNull(), eq(this.testSink.input()), argumentCaptor.capture());
Assert.assertThat(argumentCaptor.getValue().getInstanceIndex(), equalTo(0));
Assert.assertThat(argumentCaptor.getValue().getInstanceCount(), equalTo(2));
verifyNoMoreInteractions(binder);
}
Aggregations