Example usage for org.springframework.integration.mapping MessageMappingException MessageMappingException

List of usage examples for org.springframework.integration.mapping MessageMappingException MessageMappingException

Introduction

In this page you can find the example usage for org.springframework.integration.mapping MessageMappingException MessageMappingException.

Prototype

public MessageMappingException(Message<?> failedMessage, String description) 

Source Link

Usage

From source file:org.springframework.integration.ip.tcp.TcpSendingMessageHandler.java

/**
 * Method that actually does the write.//from  www.j  a v  a 2 s.  c o m
 * @param message The message to write.
 */
protected void doWrite(Message<?> message) {
    try {
        TcpConnection connection = getConnection();
        if (connection == null) {
            throw new MessageMappingException(message, "Failed to create connection");
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Got Connection " + connection.getConnectionId());
        }
        connection.send(message);
    } catch (Exception e) {
        String connectionId = null;
        if (this.connection != null) {
            connectionId = this.connection.getConnectionId();
        }
        this.connection = null;
        if (e instanceof MessageMappingException) {
            throw (MessageMappingException) e;
        }
        throw new MessageMappingException(message, "Failed to map message using " + connectionId, e);
    }
}