From 21dbbca8f8e209fc3ec66c181aef1875f1f984c8 Mon Sep 17 00:00:00 2001 From: Marius Bogoevici Date: Thu, 18 Aug 2016 12:28:11 -0400 Subject: [PATCH] Changes required by the refactoring of AbstractMessageChannelBinder --- .../binder/kafka/KafkaMessageChannelBinder.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/KafkaMessageChannelBinder.java b/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/KafkaMessageChannelBinder.java index 551606ba6..bebca99fb 100644 --- a/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/KafkaMessageChannelBinder.java +++ b/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/KafkaMessageChannelBinder.java @@ -95,7 +95,7 @@ import org.springframework.util.StringUtils; */ public class KafkaMessageChannelBinder extends AbstractMessageChannelBinder, - ExtendedProducerProperties, Collection> + ExtendedProducerProperties, Collection, String> implements ExtendedPropertiesBinder, DisposableBean { @@ -190,33 +190,33 @@ public class KafkaMessageChannelBinder extends } @Override - protected MessageHandler createProducerMessageHandler(final String name, + protected MessageHandler createProducerMessageHandler(final String destination, ExtendedProducerProperties producerProperties) throws Exception { - KafkaTopicUtils.validateTopicName(name); + KafkaTopicUtils.validateTopicName(destination); - Collection partitions = ensureTopicCreated(name, producerProperties.getPartitionCount()); + Collection partitions = ensureTopicCreated(destination, producerProperties.getPartitionCount()); if (producerProperties.getPartitionCount() < partitions.size()) { if (this.logger.isInfoEnabled()) { - this.logger.info("The `partitionCount` of the producer for topic " + name + " is " + this.logger.info("The `partitionCount` of the producer for topic " + destination + " is " + producerProperties.getPartitionCount() + ", smaller than the actual partition count of " + partitions.size() + " of the topic. The larger number will be used instead."); } } - this.topicsInUse.put(name, partitions); + this.topicsInUse.put(destination, partitions); ProducerFactory producerFB = getProducerFactory(producerProperties); KafkaTemplate kafkaTemplate = new KafkaTemplate<>(producerFB); if (this.producerListener != null) { kafkaTemplate.setProducerListener(this.producerListener); } - return new ProducerConfigurationMessageHandler(kafkaTemplate, name, producerProperties); + return new ProducerConfigurationMessageHandler(kafkaTemplate, destination, producerProperties); } @Override - protected void createProducerDestinationIfNecessary(String name, + protected String createProducerDestinationIfNecessary(String name, ExtendedProducerProperties properties) { if (this.logger.isInfoEnabled()) { this.logger.info("Using kafka topic for outbound: " + name); @@ -231,6 +231,7 @@ public class KafkaMessageChannelBinder extends } } this.topicsInUse.put(name, partitions); + return name; } private ProducerFactory getProducerFactory(