Example usage for org.springframework.messaging.handler HandlerMethod getShortLogMessage

List of usage examples for org.springframework.messaging.handler HandlerMethod getShortLogMessage

Introduction

In this page you can find the example usage for org.springframework.messaging.handler HandlerMethod getShortLogMessage.

Prototype

public String getShortLogMessage() 

Source Link

Document

Return a short representation of this handler method for log message purposes.

Usage

From source file:org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.java

protected void handleMatch(T mapping, HandlerMethod handlerMethod, String lookupDestination,
        Message<?> message) {// w w w  .j  a v  a 2 s  . c o  m
    if (logger.isDebugEnabled()) {
        logger.debug("Invoking " + handlerMethod.getShortLogMessage());
    }
    handlerMethod = handlerMethod.createWithResolvedBean();
    InvocableHandlerMethod invocable = new InvocableHandlerMethod(handlerMethod);
    invocable.setMessageMethodArgumentResolvers(this.argumentResolvers);
    try {
        Object returnValue = invocable.invoke(message);
        MethodParameter returnType = handlerMethod.getReturnType();
        if (void.class == returnType.getParameterType()) {
            return;
        }
        if (returnValue != null && this.returnValueHandlers.isAsyncReturnValue(returnValue, returnType)) {
            ListenableFuture<?> future = this.returnValueHandlers.toListenableFuture(returnValue, returnType);
            if (future != null) {
                future.addCallback(new ReturnValueListenableFutureCallback(invocable, message));
            }
        } else {
            this.returnValueHandlers.handleReturnValue(returnValue, returnType, message);
        }
    } catch (Exception ex) {
        processHandlerMethodException(handlerMethod, ex, message);
    } catch (Throwable ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Error while processing message " + message, ex);
        }
    }
}

From source file:org.springframework.messaging.handler.invocation.reactive.AbstractMethodMessageHandler.java

@Nullable
private Match<T> getHandlerMethod(Message<?> message) {
    List<Match<T>> matches = new ArrayList<>();

    RouteMatcher.Route destination = getDestination(message);
    List<T> mappingsByUrl = destination != null ? this.destinationLookup.get(destination.value()) : null;
    if (mappingsByUrl != null) {
        addMatchesToCollection(mappingsByUrl, message, matches);
    }//from   ww  w. j  a va2  s. c om
    if (matches.isEmpty()) {
        // No direct hits, go through all mappings
        Set<T> allMappings = this.handlerMethods.keySet();
        addMatchesToCollection(allMappings, message, matches);
    }
    if (matches.isEmpty()) {
        handleNoMatch(destination, message);
        return null;
    }
    Comparator<Match<T>> comparator = new MatchComparator(getMappingComparator(message));
    matches.sort(comparator);
    if (logger.isTraceEnabled()) {
        logger.trace("Found " + matches.size() + " handler methods: " + matches);
    }
    Match<T> bestMatch = matches.get(0);
    if (matches.size() > 1) {
        Match<T> secondBestMatch = matches.get(1);
        if (comparator.compare(bestMatch, secondBestMatch) == 0) {
            HandlerMethod m1 = bestMatch.handlerMethod;
            HandlerMethod m2 = secondBestMatch.handlerMethod;
            throw new IllegalStateException(
                    "Ambiguous handler methods mapped for destination '" + destination.value() + "': {"
                            + m1.getShortLogMessage() + ", " + m2.getShortLogMessage() + "}");
        }
    }
    return bestMatch;
}