Example usage for org.springframework.messaging MessageHandlingException getFailedMessage

List of usage examples for org.springframework.messaging MessageHandlingException getFailedMessage

Introduction

In this page you can find the example usage for org.springframework.messaging MessageHandlingException getFailedMessage.

Prototype

@Nullable
    public Message<?> getFailedMessage() 

Source Link

Usage

From source file:it.pcan.test.integration.amqp.ErrorHandler.java

@ServiceActivator
public Message handleException(Message msg) {
    System.out.println("Exception thrown: " + msg);
    MessageHandlingException payload = (MessageHandlingException) msg.getPayload();
    MessageHeaders headers = payload.getFailedMessage().getHeaders();
    HashMap<String, Object> newHeaders = new HashMap<>(headers);

    newHeaders.putAll(msg.getHeaders());
    Throwable cause = payload.getCause();
    RuntimeException ex = (cause instanceof RuntimeException) ? (RuntimeException) cause
            : new RuntimeException(cause);

    Message m = new GenericMessage(new RuntimeExceptionHolder(ex), newHeaders);
    return m;//from w ww.ja  v  a  2  s.c om
}