From e8611cf9f717f6f527e6f8e9ec7469fa18278b1e Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Fri, 2 Aug 2019 20:29:47 +0200 Subject: [PATCH] GH-1776 Added support for beanName to DirectWithAttributesChannel Resolves #1776 --- .../DirectWithAttributesChannel.java | 4 ++++ .../SourceToFunctionsSupportTests.java | 19 ++----------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/messaging/DirectWithAttributesChannel.java b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/messaging/DirectWithAttributesChannel.java index 0725adcf1..cc6ebeaac 100644 --- a/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/messaging/DirectWithAttributesChannel.java +++ b/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/messaging/DirectWithAttributesChannel.java @@ -37,4 +37,8 @@ public class DirectWithAttributesChannel extends DirectChannel { return this.attributes.get(key); } + @Override + public String getBeanName() { + return this.getComponentName(); + } } diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/SourceToFunctionsSupportTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/SourceToFunctionsSupportTests.java index bb39c06bb..5fafe292b 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/SourceToFunctionsSupportTests.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/SourceToFunctionsSupportTests.java @@ -252,28 +252,13 @@ public class SourceToFunctionsSupportTests { public static class ExistingMessageSourceConfiguration { @Bean - public IntegrationFlow messageSourceFlow() { + public IntegrationFlow messageSourceFlow(Source source) { Supplier> messageSource = () -> MessageBuilder .withPayload("hello function") .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN) .build(); - return IntegrationFlows.from(messageSource).channel("output").get(); + return IntegrationFlows.from(messageSource).channel(source.output()).get(); } } - - @EnableBinding(Source.class) - public static class ExistingMessageSourceConfigurationNoContentTypeSet { - - @Bean - public IntegrationFlow messageSourceFlow() { - Supplier> messageSource = () -> MessageBuilder - .withPayload("hello function") - .setHeader(MessageHeaders.CONTENT_TYPE, "application/octet-stream") - .build(); - return IntegrationFlows.from(messageSource).channel("output").get(); - } - - } - }