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:
Mark Fisher
2008-01-15 22:14:02 +00:00
parent 6cd1e7be7c
commit 517eb654f3
3 changed files with 14 additions and 5 deletions

View File

@@ -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() +

View File

@@ -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)) {

View File

@@ -28,8 +28,6 @@ public interface MessageEndpoint extends MessageHandler {
String getName();
MessageHandler getHandler();
Subscription getSubscription();
ConcurrencyPolicy getConcurrencyPolicy();