diff --git a/spring-kafka/src/main/java/org/springframework/kafka/core/ProducerFactory.java b/spring-kafka/src/main/java/org/springframework/kafka/core/ProducerFactory.java index 5da1d21a6b..8d574a9d04 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/core/ProducerFactory.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/core/ProducerFactory.java @@ -35,6 +35,7 @@ * * @author Gary Russell * @author Thomas Strauß + * @author Kwon YongHyun */ public interface ProducerFactory { @@ -43,6 +44,11 @@ public interface ProducerFactory { */ Duration DEFAULT_PHYSICAL_CLOSE_TIMEOUT = Duration.ofSeconds(30); + /** + * Error message for unsupported factory methods. + */ + String FACTORY_DOES_NOT_SUPPORT_METHOD = "This factory does not support this method"; + /** * Create a producer which will be transactional if the factory is so configured. * @return the producer. @@ -57,7 +63,7 @@ public interface ProducerFactory { * @since 2.3 */ default Producer createProducer(@Nullable @SuppressWarnings("unused") String txIdPrefix) { - throw new UnsupportedOperationException("This factory does not support this method"); + throw new UnsupportedOperationException(FACTORY_DOES_NOT_SUPPORT_METHOD); } /** @@ -67,7 +73,7 @@ default Producer createProducer(@Nullable @SuppressWarnings("unused") Stri * @see #transactionCapable() */ default Producer createNonTransactionalProducer() { - throw new UnsupportedOperationException("This factory does not support this method"); + throw new UnsupportedOperationException(FACTORY_DOES_NOT_SUPPORT_METHOD); } /**