2
votes

I have a gateway that gets input from the MVC layer. The input is sent to a outbound gateway (REST call). the response is then sent through a filter to validate the response. How do i send the discard channel (dropped message) back to the gateway. I need to send the invalid response back to the gateway or throw an exception back to the gateway.

1

1 Answers

1
votes

You might not need to worry about discardChannel. There is this property for your gateway case:

/**
 * 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) {