List of usage examples for org.springframework.amqp.rabbit.listener.adapter ReplyFailureException ReplyFailureException
public ReplyFailureException(String msg, Throwable cause)
From source file:org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener.java
/** * Handle the given result object returned from the listener method, sending a * response message back.//from w ww . j av a 2s.c o m * @param resultArg the result object to handle (never <code>null</code>) * @param request the original request message * @param channel the Rabbit channel to operate on (may be <code>null</code>) * @param source the source data for the method invocation - e.g. * {@code o.s.messaging.Message<?>}; may be null * @throws Exception if thrown by Rabbit API methods * @see #buildMessage * @see #postProcessResponse * @see #getReplyToAddress(Message, Object, Object) * @see #sendResponse */ protected void handleResult(Object resultArg, Message request, Channel channel, Object source) throws Exception { if (channel != null) { if (this.logger.isDebugEnabled()) { this.logger.debug( "Listener method returned result [" + resultArg + "] - generating response message for it"); } try { Object result = resultArg instanceof ResultHolder ? ((ResultHolder) resultArg).result : resultArg; Message response = buildMessage(channel, result); postProcessResponse(request, response); Address replyTo = getReplyToAddress(request, source, resultArg); sendResponse(channel, replyTo, response); } catch (Exception ex) { throw new ReplyFailureException("Failed to send reply with payload '" + resultArg + "'", ex); } } else if (this.logger.isWarnEnabled()) { this.logger.warn("Listener method returned result [" + resultArg + "]: not generating response message for it because no Rabbit Channel given"); } }