INT-2951 Add Context Id to Dispatcher has no Subs.

https://jira.springsource.org/browse/INT-2951

Provide the context id in the 'Dispatcher has no Subscribers'
message.

Ease debugging when more than one context in an application.

INT-2951 Polishing

PR Comments - add quotes to context Id in log message.

Polishing

INT-2951 Polishing

Change IOS to have a simple getApplicationContextId() and
add a method getFullChannelName() to AbstractMessageChannel.
This commit is contained in:
Gary Russell
2013-03-04 11:33:35 -05:00
committed by Gunnar Hillert
parent e255399415
commit b904fde5c0
10 changed files with 115 additions and 55 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -191,8 +191,9 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
String topicName = SubscribableRedisChannel.this.topicName;
topicName = StringUtils.hasText(topicName) ? topicName : "unknown";
throw new MessageDeliveryException(siMessage, e.getMessage()
+ " for redis-channel "
+ topicName + ".", e);
+ " for redis-channel '"
+ topicName + "' (" + SubscribableRedisChannel.this.getFullChannelName()
+ ").", e);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -45,9 +45,9 @@ import org.springframework.util.ReflectionUtils;
* @since 2.0
*/
public class SubscribableRedisChannelTests extends RedisAvailableTests{
@Test
@Test
@RedisAvailable
public void pubSubChanneTest() throws Exception{
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
@@ -77,6 +77,7 @@ public class SubscribableRedisChannelTests extends RedisAvailableTests{
connectionFactory.afterPropertiesSet();
SubscribableRedisChannel channel = new SubscribableRedisChannel(connectionFactory, "si.test.channel.no.subs");
channel.setBeanName("dhnsChannel");
channel.setBeanFactory(mock(BeanFactory.class));
channel.afterPropertiesSet();
@@ -94,7 +95,7 @@ public class SubscribableRedisChannelTests extends RedisAvailableTests{
catch (InvocationTargetException e) {
Throwable cause = e.getCause();
assertNotNull(cause);
assertEquals("Dispatcher has no subscribers for redis-channel si.test.channel.no.subs.", cause.getMessage());
assertEquals("Dispatcher has no subscribers for redis-channel 'si.test.channel.no.subs' (dhnsChannel).", cause.getMessage());
}
}