提问者:小点点

Spring集成出站网关响应验证


我有一个从MVC层获取输入的网关。输入被发送到出站网关(REST调用)。然后通过过滤器发送响应以验证响应。如何将丢弃通道(丢弃消息)发送回网关。我需要将无效响应发送回网关或将异常抛回网关。


共1个答案

匿名用户

您可能不需要担心discardChannel。您的网关案例有这个属性:

/**
 * Specify whether this filter should throw a
 * {@link MessageRejectedException} when its selector does not accept a
 * Message. The default value is <code>false</code> meaning that rejected
 * Messages will be quietly dropped or sent to the discard channel if
 * available. Typically this value would not be <code>true</code> when
 * a discard channel is provided, but if so, it will still apply
 * (in such a case, the Message will be sent to the discard channel,
 * and <em>then</em> the exception will be thrown).
 * @param throwExceptionOnRejection true if an exception should be thrown.
 * @see #setDiscardChannel(MessageChannel)
 */
public void setThrowExceptionOnRejection(boolean throwExceptionOnRejection) {