diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AbstractPollingInboundChannelAdapterParser.java b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AbstractPollingInboundChannelAdapterParser.java
index 2e7d981a87..fd1771761b 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AbstractPollingInboundChannelAdapterParser.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/AbstractPollingInboundChannelAdapterParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,13 +42,13 @@ public abstract class AbstractPollingInboundChannelAdapterParser extends Abstrac
if (source == null) {
parserContext.getReaderContext().error("failed to parse source", element);
}
+ BeanDefinitionBuilder adapterBuilder = BeanDefinitionBuilder
+ .genericBeanDefinition(SourcePollingChannelAdapterFactoryBean.class);
- String channelAdapterId = this.resolveId(element, (AbstractBeanDefinition) source, parserContext);
+ String channelAdapterId = this.resolveId(element, adapterBuilder.getRawBeanDefinition(), parserContext);
String sourceBeanName = channelAdapterId + ".source";
parserContext.getRegistry().registerBeanDefinition(sourceBeanName, (BeanDefinition) source);
- BeanDefinitionBuilder adapterBuilder = BeanDefinitionBuilder
- .genericBeanDefinition(SourcePollingChannelAdapterFactoryBean.class);
adapterBuilder.addPropertyReference("source", sourceBeanName);
adapterBuilder.addPropertyReference("outputChannel", channelName);
IntegrationNamespaceUtils.setValueIfAttributeDefined(adapterBuilder, element, "send-timeout");
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelAdapterParserTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelAdapterParserTests-context.xml
index d7a481bcc0..933963f608 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelAdapterParserTests-context.xml
+++ b/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelAdapterParserTests-context.xml
@@ -46,4 +46,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelAdapterParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelAdapterParserTests.java
index 0d4f1625bf..0d96ea5e01 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelAdapterParserTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/config/ChannelAdapterParserTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2011 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -280,6 +280,20 @@ public class ChannelAdapterParserTests {
new ClassPathXmlApplicationContext("InboundChannelAdapterInnerBeanWithExpression-fail-context.xml", this.getClass());
}
+ @Test
+ public void testMessageSourceUniqueIds() {
+ PollableChannel channel1 = this.applicationContext.getBean("channelAdapter1Channel", PollableChannel.class);
+ PollableChannel channel2 = this.applicationContext.getBean("channelAdapter2Channel", PollableChannel.class);
+
+ for (int i = 0; i < 10; i++) {
+ Message> message = channel1.receive(5000);
+ assertNotNull(message);
+ assertEquals(i + 1, message.getPayload());
+ message = channel2.receive(5000);
+ assertEquals(i + 1, message.getPayload());
+ }
+ }
+
public static class SampleBean {
private String message = "hello";