List of usage examples for org.springframework.kafka.listener ListenerExecutionFailedException ListenerExecutionFailedException
public ListenerExecutionFailedException(String message, @Nullable Throwable cause)
From source file:org.springframework.kafka.listener.adapter.MessagingMessageListenerAdapter.java
/** * Invoke the handler, wrapping any exception to a {@link ListenerExecutionFailedException} * with a dedicated error message./*from w ww.ja v a2s . c o m*/ * @param data the data to process during invocation. * @param acknowledgment the acknowledgment to use if any. * @param message the message to process. * @return the result of invocation. */ protected final Object invokeHandler(Object data, Acknowledgment acknowledgment, Message<?> message) { try { if (data instanceof List && !this.isConsumerRecordList) { return this.handlerMethod.invoke(message, acknowledgment); } else { return this.handlerMethod.invoke(message, data, acknowledgment); } } catch (org.springframework.messaging.converter.MessageConversionException ex) { throw new ListenerExecutionFailedException(createMessagingErrorMessage( "Listener method could not " + "be invoked with the incoming message", message.getPayload()), new MessageConversionException("Cannot handle message", ex)); } catch (MessagingException ex) { throw new ListenerExecutionFailedException(createMessagingErrorMessage( "Listener method could not " + "be invoked with the incoming message", message.getPayload()), ex); } catch (Exception ex) { throw new ListenerExecutionFailedException("Listener method '" + this.handlerMethod.getMethodAsString(message.getPayload()) + "' threw exception", ex); } }