Skip to content

Commit 08ebc66

Browse files
artembilangaryrussell
authored andcommitted
INT-4485: Don't register bean twice for DSL Specs
JIRA: https://jira.spring.io/browse/INT-4485 The `IntegrationFlowBeanPostProcessor` performs extra bean registration for the `IntegrationComponentSpec.get()` result. Essentially it is going to be the same object in the end, but during bean registration phase we end up with names conflict. * Remove an explicit `registerComponent()` for the `IntegrationComponentSpec.get()` * Modify `CorrelationHandlerTests` for all possible usage for the `MessageChannelSpec`, which is essentially a `FactoryBean` **Cherry-pick to 5.0.x**
1 parent 1ce656e commit 08ebc66

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

spring-integration-core/src/main/java/org/springframework/integration/config/dsl/IntegrationFlowBeanPostProcessor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ private Object processIntegrationFlowImpl(IntegrationFlow flow, String beanName)
281281
}
282282

283283
private void processIntegrationComponentSpec(IntegrationComponentSpec<?, ?> bean) {
284-
registerComponent(bean.get(), generateBeanName(bean.get(), bean.getId()));
285284
if (bean instanceof ComponentsRegistration) {
286285
Map<Object, String> componentsToRegister = ((ComponentsRegistration) bean).getComponentsToRegister();
287286
if (!CollectionUtils.isEmpty(componentsToRegister)) {

spring-integration-core/src/test/java/org/springframework/integration/dsl/correlation/CorrelationHandlerTests.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.springframework.integration.config.EnableIntegration;
4444
import org.springframework.integration.dsl.IntegrationFlow;
4545
import org.springframework.integration.dsl.IntegrationFlows;
46+
import org.springframework.integration.dsl.channel.MessageChannelSpec;
4647
import org.springframework.integration.dsl.channel.MessageChannels;
4748
import org.springframework.integration.handler.MessageTriggerAction;
4849
import org.springframework.integration.support.MessageBuilder;
@@ -176,10 +177,15 @@ public TestSplitterPojo testSplitterData() {
176177
}
177178

178179
@Bean
179-
public IntegrationFlow splitResequenceFlow() {
180+
public MessageChannelSpec<?, ?> executorChannel() {
181+
return MessageChannels.executor(taskExecutor());
182+
}
183+
184+
@Bean
185+
public IntegrationFlow splitResequenceFlow(MessageChannel executorChannel) {
180186
return f -> f.enrichHeaders(s -> s.header("FOO", "BAR"))
181187
.split("testSplitterData", "buildList", c -> c.applySequence(false))
182-
.channel(MessageChannels.executor(taskExecutor()))
188+
.channel(executorChannel)
183189
.split(Message.class, Message<?>::getPayload, c -> c.applySequence(false))
184190
.channel(MessageChannels.executor(taskExecutor()))
185191
.split(s -> s
@@ -228,6 +234,11 @@ public IntegrationFlow publishSubscribeAggregateFlow() {
228234
.channel(MessageChannels.queue("subscriberAggregateResult"));
229235
}
230236

237+
@Bean
238+
public MessageChannelSpec<?, ?> barrierResults() {
239+
return MessageChannels.queue("barrierResults");
240+
}
241+
231242
@Bean
232243
public IntegrationFlow barrierFlow() {
233244
return f -> f
@@ -239,13 +250,18 @@ public IntegrationFlow barrierFlow() {
239250
.skip(1)
240251
.findFirst()
241252
.get()))
242-
.channel(MessageChannels.queue("barrierResults"));
253+
.channel("barrierResults");
254+
}
255+
256+
@Bean
257+
public MessageChannelSpec<?, ?> releaseChannel() {
258+
return MessageChannels.queue("releaseChannel");
243259
}
244260

245261
@Bean
246262
@DependsOn("barrierFlow")
247263
public IntegrationFlow releaseBarrierFlow(MessageTriggerAction barrierTriggerAction) {
248-
return IntegrationFlows.from(MessageChannels.queue("releaseChannel"))
264+
return IntegrationFlows.from(releaseChannel())
249265
.trigger(barrierTriggerAction,
250266
e -> e.poller(p -> p.fixedDelay(100)))
251267
.get();

0 commit comments

Comments
 (0)