INT-886 Failed dispatching due to "no subscribers" now provides a more meaningful exception message.

This commit is contained in:
Mark Fisher
2009-12-10 00:13:48 +00:00
parent 24201290e6
commit 538b13b757
7 changed files with 50 additions and 22 deletions

View File

@@ -25,7 +25,9 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessagingException;
import org.springframework.integration.core.MessageHistory.ComponentType;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.util.Assert;
/**
@@ -117,9 +119,18 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName
if (message == null) {
return false;
}
boolean sent = this.doSend(message, timeout);
this.interceptors.postSend(message, this, sent);
return sent;
try {
boolean sent = this.doSend(message, timeout);
this.interceptors.postSend(message, this, sent);
return sent;
}
catch (MessagingException e) {
throw e;
}
catch (Exception e) {
throw new MessageDeliveryException(message,
"failed to send Message to channel '" + this.getName() + "'", e);
}
}
public String toString() {

View File

@@ -94,7 +94,7 @@ public class UnicastingDispatcher extends AbstractDispatcher {
boolean success = false;
Iterator<MessageHandler> handlerIterator = this.getHandlerIterator(message);
if (!handlerIterator.hasNext()) {
throw new MessageDeliveryException(message, "Dispatcher has no subscribers.");
throw new IllegalStateException("Dispatcher has no subscribers.");
}
List<RuntimeException> exceptions = new ArrayList<RuntimeException>();
while (success == false && handlerIterator.hasNext()) {

View File

@@ -38,8 +38,8 @@ import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHeaders;
import org.springframework.integration.message.ErrorMessage;
import org.springframework.integration.message.MessageDeliveryException;
import org.springframework.integration.message.MessageHandler;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.util.Assert;
/**
@@ -206,7 +206,7 @@ public class DelayHandler implements MessageHandler, Ordered, BeanFactoryAware,
releaseMessage(message);
}
catch (Exception e) {
Exception exception = new MessageDeliveryException(message, "Failed to deliver Message after delay.", e);
Exception exception = new MessageHandlingException(message, "Failed to deliver Message after delay.", e);
MessageChannel errorChannel = resolveErrorChannelIfPossible(message);
if (errorChannel != null) {
ErrorMessage errorMessage = new ErrorMessage(exception);