Enabled auto-create for endpoint's defaultOutputChannel if necessary, and modified the EndpointParser to use channel names instead of RuntimeBeanReference.
This commit is contained in:
@@ -244,12 +244,23 @@ public class MessageBus implements ChannelRegistry, ApplicationContextAware, Lif
|
||||
"'. Consider enabling the 'autoCreateChannels' option for the message bus.");
|
||||
}
|
||||
if (this.logger.isInfoEnabled()) {
|
||||
logger.info("auto-creating channel '" + channel.getName() + "'");
|
||||
logger.info("auto-creating channel '" + channelName + "'");
|
||||
}
|
||||
channel = new SimpleChannel();
|
||||
this.registerChannel(channelName, channel);
|
||||
}
|
||||
}
|
||||
if (endpoint instanceof DefaultMessageEndpoint) {
|
||||
String outputChannelName = ((DefaultMessageEndpoint) endpoint).getDefaultOutputChannelName();
|
||||
if (outputChannelName != null && this.lookupChannel(outputChannelName) == null) {
|
||||
if (!this.autoCreateChannels) {
|
||||
throw new MessagingConfigurationException("Unknown channel '" + outputChannelName +
|
||||
"' configured as 'default-output' for endpoint '" + endpoint.getName() +
|
||||
"'. Consider enabling the 'autoCreateChannels' option for the message bus.");
|
||||
}
|
||||
this.registerChannel(outputChannelName, new SimpleChannel());
|
||||
}
|
||||
}
|
||||
this.registerWithDispatcher(channel, endpoint, subscription.getSchedule(), endpoint.getConcurrencyPolicy());
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("activated subscription to channel '" + channel.getName() +
|
||||
|
||||
@@ -52,7 +52,7 @@ public class EndpointParser implements BeanDefinitionParser {
|
||||
|
||||
private static final String SUBSCRIPTION_PROPERTY = "subscription";
|
||||
|
||||
private static final String CHANNEL_PROPERTY = "channel";
|
||||
private static final String CHANNEL_NAME_PROPERTY = "channelName";
|
||||
|
||||
private static final String DEFAULT_OUTPUT_CHANNEL_ATTRIBUTE = "default-output-channel";
|
||||
|
||||
@@ -95,7 +95,7 @@ public class EndpointParser implements BeanDefinitionParser {
|
||||
String inputChannel = element.getAttribute(INPUT_CHANNEL_ATTRIBUTE);
|
||||
RootBeanDefinition subscriptionDef = new RootBeanDefinition(Subscription.class);
|
||||
if (StringUtils.hasText(inputChannel)) {
|
||||
subscriptionDef.getPropertyValues().addPropertyValue(CHANNEL_PROPERTY, new RuntimeBeanReference(inputChannel));
|
||||
subscriptionDef.getPropertyValues().addPropertyValue(CHANNEL_NAME_PROPERTY, inputChannel);
|
||||
}
|
||||
String defaultOutputChannel = element.getAttribute(DEFAULT_OUTPUT_CHANNEL_ATTRIBUTE);
|
||||
if (StringUtils.hasText(defaultOutputChannel)) {
|
||||
|
||||
@@ -28,8 +28,6 @@ public interface MessageEndpoint extends MessageHandler {
|
||||
|
||||
String getName();
|
||||
|
||||
MessageHandler getHandler();
|
||||
|
||||
Subscription getSubscription();
|
||||
|
||||
ConcurrencyPolicy getConcurrencyPolicy();
|
||||
|
||||
Reference in New Issue
Block a user