Add ReplyRequiredException

This commit is contained in:
Mark Fisher
2011-09-21 13:27:47 -04:00
parent f9952da461
commit 0439909b8a
5 changed files with 52 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 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.
@@ -19,7 +19,6 @@ package org.springframework.integration.handler;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.core.MessagingTemplate;
@@ -69,8 +68,8 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
}
/**
* Flag wether reply is required. If true an incoming message MUST result in a reply message being sent.
* If false an incoming message MAY result in a reply message being sent
* Flag whether a reply is required. If true an incoming message MUST result in a reply message being sent.
* If false an incoming message MAY result in a reply message being sent. Default is false.
*/
public void setRequiresReply(boolean requiresReply) {
this.requiresReply = requiresReply;
@@ -101,8 +100,8 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
this.handleResult(result, requestHeaders);
}
else if (this.requiresReply) {
throw new MessageHandlingException(message, "handler '" + this
+ "' requires a reply, but no reply was received");
throw new ReplyRequiredException(message, "No reply produced by handler '" +
this.getComponentName() + "', and its 'requiresReply' property is set to true.");
}
else if (logger.isDebugEnabled()) {
logger.debug("handler '" + this + "' produced no reply for request Message: " + message);

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2002-2011 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.handler;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
/**
* Exception that indicates no reply message is produced by a handler
* that does have a value of true for the 'requiresReply' property.
*
* @author Mark Fisher
* @since 2.1
*/
@SuppressWarnings("serial")
public class ReplyRequiredException extends MessagingException {
public ReplyRequiredException(Message<?> failedMessage, String description) {
super(failedMessage, description);
}
}