@Override protected void handleMissingValue(String headerName, MethodParameter parameter, Message<?> message) { throw new MessageHandlingException(message, "Missing header '" + headerName + "' for method parameter type [" + parameter.getParameterType() + "]"); }
@Override protected void handleMissingValue(String name, MethodParameter parameter, Message<?> message) { throw new MessageHandlingException(message, "Missing path template variable '" + name + "' for method parameter type [" + parameter.getParameterType() + "]"); }
/** * Launches a Batch Job using the provided request {@link Message}. The payload * of the {@link Message} <em>must</em> be an instance of {@link JobLaunchRequest}. * * @param requestMessage must not be null. * @return Generally a {@link JobExecution} will always be returned. An * exception ({@link MessageHandlingException}) will only be thrown if there * is a failure to start the job. The cause of the exception will be a * {@link JobExecutionException}. * * @throws MessageHandlingException when a job cannot be launched */ @Override protected Object handleRequestMessage(Message<?> requestMessage) { Assert.notNull(requestMessage, "The provided requestMessage must not be null."); final Object payload = requestMessage.getPayload(); Assert.isInstanceOf(JobLaunchRequest.class, payload, "The payload must be of type JobLaunchRequest."); final JobLaunchRequest jobLaunchRequest = (JobLaunchRequest) payload; final JobExecution jobExecution; try { jobExecution = this.jobLaunchingMessageHandler.launch(jobLaunchRequest); } catch (JobExecutionException e) { throw new MessageHandlingException(requestMessage, e); } return jobExecution; }
new MessageHandlingException(message, "Unexpected handler method invocation error", ex); processHandlerMethodException(handlerMethod, handlingException, message);
private MessageHandlingException wrapToMessageHandlingExceptionIfNecessary(Message<?> message, String description, Throwable cause) { if (cause instanceof MessageHandlingException) { throw (MessageHandlingException) cause; } else { throw new MessageHandlingException(message, description, cause); } }
@Override protected void handleMissingValue(String headerName, MethodParameter parameter, Message<?> message) { throw new MessageHandlingException(message, "Missing header '" + headerName + "' for method parameter type [" + parameter.getParameterType() + "]"); }
@Override protected void handleMissingValue(String name, MethodParameter parameter, Message<?> message) { throw new MessageHandlingException(message, "Missing path template variable '" + name + "' for method parameter type [" + parameter.getParameterType() + "]"); }
protected TcpConnection obtainConnection(Message<?> message) { TcpConnection connection; Assert.notNull(this.clientConnectionFactory, "'clientConnectionFactory' cannot be null"); try { connection = this.clientConnectionFactory.getConnection(); } catch (Exception e) { logger.error("Error creating connection", e); throw new MessageHandlingException(message, "Failed to obtain a connection", e); } return connection; }
@Override public T processMessage(Message<?> message) { try { return this.delegate.process(message); } catch (Exception e) { throw new MessageHandlingException(message, e); } }
public void handle(Message<?> message) { throw new MessageHandlingException(message, "intentional test failure"); }
public WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer, SubProtocolHandlerRegistry protocolHandlerRegistry) { Assert.notNull(webSocketContainer, "'webSocketContainer' must not be null"); Assert.notNull(protocolHandlerRegistry, "'protocolHandlerRegistry' must not be null"); this.webSocketContainer = webSocketContainer; this.server = this.webSocketContainer instanceof ServerWebSocketContainer; this.subProtocolHandlerRegistry = protocolHandlerRegistry; this.subProtocolHandlerChannel = new FixedSubscriberChannel(message -> { try { handleMessageAndSend(message); } catch (Exception e) { throw new MessageHandlingException(message, e); } }); }
private Iterator<Object> messageToFileIterator(Message<?> message, Reader reader, String filePath) { BufferedReader bufferedReader = wrapToBufferedReader(message, reader); String firstLineAsHeader = null; if (this.firstLineHeaderName != null) { try { firstLineAsHeader = bufferedReader.readLine(); } catch (IOException e) { throw new MessageHandlingException(message, "IOException while reading first line", e); } } return new FileIterator(message, bufferedReader, firstLineAsHeader, filePath); }
@Override protected String put(Message<?> message, Session<FTPFile> session, String subDirectory) { try { return doInWorkingDirectory(message, session, () -> super.put(message, session, subDirectory)); } catch (IOException e) { throw new MessageHandlingException(message, "Cannot handle PUT command", e); } }
@Override protected List<String> mPut(Message<?> message, Session<FTPFile> session, File localDir) { try { return doInWorkingDirectory(message, session, () -> super.mPut(message, session, localDir)); } catch (IOException e) { throw new MessageHandlingException(message, "Cannot handle MPUT command", e); } }
@Override protected void handleMessageInternal(Message<?> message) throws Exception { Object mqttMessage = this.converter.fromMessage(message, Object.class); String topic = this.topicProcessor.processMessage(message); if (topic == null && this.defaultTopic == null) { throw new MessageHandlingException(message, "No topic could be determined from the message and no default topic defined"); } publish(topic == null ? this.defaultTopic : topic, mqttMessage, message); }
/** * Executes the script and returns the result. */ @Override public final T processMessage(Message<?> message) { try { ScriptSource source = this.getScriptSource(message); Map<String, Object> variables = this.scriptVariableGenerator.generateScriptVariables(message); return this.executeScript(source, variables); } catch (Exception e) { throw new MessageHandlingException(message, "failed to execute script", e); } }
@Bean @ServiceActivator(inputChannel = "annotatedBeanMessageHandlerChannel2") @IdempotentReceiver("idempotentReceiverInterceptor") public MessageHandler messageHandler2() { return message -> { if (message.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)) { throw new MessageHandlingException(message, "duplicate message has been received"); } }; }
public String echoWithMessagingException(String value) { throw new MessageHandlingException(new GenericMessage<String>(value)); }
private void produceConnectAckMessage(Message<?> message, SimpMessageHeaderAccessor headerAccessor) { String sessionId = headerAccessor.getSessionId(); SimpMessageHeaderAccessor connectAck = SimpMessageHeaderAccessor.create(SimpMessageType.CONNECT_ACK); connectAck.setSessionId(sessionId); connectAck.setHeader(SimpMessageHeaderAccessor.CONNECT_MESSAGE_HEADER, message); Message<byte[]> ackMessage = MessageBuilder.createMessage(EMPTY_PAYLOAD, connectAck.getMessageHeaders()); WebSocketSession session = this.webSocketContainer.getSession(sessionId); try { this.subProtocolHandlerRegistry.findProtocolHandler(session).handleMessageToClient(session, ackMessage); } catch (Exception e) { throw new MessageHandlingException(message, "Error sending connect ack message", e); } }
@Test public void testExceptionTypeRouteFlow() { Message<?> failedMessage = new GenericMessage<>("foo"); IllegalArgumentException rootCause = new IllegalArgumentException("bad argument"); RuntimeException middleCause = new RuntimeException(rootCause); MessageHandlingException error = new MessageHandlingException(failedMessage, "failed", middleCause); ErrorMessage message = new ErrorMessage(error); this.exceptionTypeRouteFlowInput.send(message); assertNotNull(this.illegalArgumentChannel.receive(1000)); assertNull(this.exceptionRouterDefaultChannel.receive(0)); assertNull(this.runtimeExceptionChannel.receive(0)); assertNull(this.messageHandlingExceptionChannel.receive(0)); }