Modified the 'onFailure' method signature in MessageDeliveryAware so that any Exception can be passed along with a separate Message parameter instead of always expecting a MessagingException.
This commit is contained in:
@@ -116,7 +116,7 @@ public abstract class AbstractEndpoint implements MessageEndpoint, BeanNameAware
|
||||
}
|
||||
else {
|
||||
this.handleException(new MessageHandlingException(message,
|
||||
"failure occurred in endpoint's send operation", e));
|
||||
"failure occurred in endpoint '" + this.toString() + "'", e));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,12 +41,11 @@ public class InboundChannelAdapter extends AbstractEndpoint {
|
||||
return sent;
|
||||
}
|
||||
catch (Exception e) {
|
||||
MessagingException exception = (e instanceof MessagingException) ? (MessagingException) e
|
||||
: new MessageDeliveryException(message, "channel-adapter failed to send message to target");
|
||||
if (this.getSource() instanceof MessageDeliveryAware) {
|
||||
((MessageDeliveryAware) this.getSource()).onFailure(exception);
|
||||
((MessageDeliveryAware) this.getSource()).onFailure(message, e);
|
||||
}
|
||||
return false;
|
||||
throw (e instanceof MessagingException) ? (MessagingException) e
|
||||
: new MessageDeliveryException(message, "channel adapter failed to send message to target", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,6 @@ public interface MessageDeliveryAware {
|
||||
/**
|
||||
* Callback method invoked after a message delivery failure.
|
||||
*/
|
||||
void onFailure(MessagingException exception);
|
||||
void onFailure(Message<?> failedMessage, Throwable t);
|
||||
|
||||
}
|
||||
|
||||
@@ -226,8 +226,9 @@ public class MessageExchangeTemplate implements InitializingBean {
|
||||
}
|
||||
|
||||
private boolean doReceiveAndForward(PollableSource<?> source, MessageTarget target) {
|
||||
Message<?> message = null;
|
||||
try {
|
||||
Message<?> message = this.doReceive(source);
|
||||
message = this.doReceive(source);
|
||||
if (message == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -237,18 +238,23 @@ public class MessageExchangeTemplate implements InitializingBean {
|
||||
((MessageDeliveryAware) source).onSend(message);
|
||||
}
|
||||
else {
|
||||
((MessageDeliveryAware) source).onFailure(new MessageDeliveryException(message, "failed to send message"));
|
||||
((MessageDeliveryAware) source).onFailure(message, new MessageDeliveryException(message, "failed to send message"));
|
||||
}
|
||||
}
|
||||
return sent;
|
||||
}
|
||||
catch (Exception e) {
|
||||
MessagingException exception = (e instanceof MessagingException) ? (MessagingException) e
|
||||
: new MessagingException("exception occurred in receive-and-forward exchange", e);
|
||||
if (source instanceof MessageDeliveryAware) {
|
||||
((MessageDeliveryAware) source).onFailure(exception);
|
||||
((MessageDeliveryAware) source).onFailure(message, e);
|
||||
}
|
||||
throw exception;
|
||||
if (e instanceof MessagingException) {
|
||||
throw (MessagingException) e;
|
||||
}
|
||||
String description = "exception occurred in receive-and-forward exchange";
|
||||
if (message != null) {
|
||||
throw new MessagingException(message, description, e);
|
||||
}
|
||||
throw new MessagingException(description, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user