org.springframework.messaging.MessageHandlingException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(230)

本文整理了Java中org.springframework.messaging.MessageHandlingException.<init>()方法的一些代码示例,展示了MessageHandlingException.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MessageHandlingException.<init>()方法的具体详情如下:
包路径:org.springframework.messaging.MessageHandlingException
类名称:MessageHandlingException
方法名:<init>

MessageHandlingException.<init>介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

  1. @Override
  2. protected void handleMissingValue(String headerName, MethodParameter parameter, Message<?> message) {
  3. throw new MessageHandlingException(message, "Missing header '" + headerName +
  4. "' for method parameter type [" + parameter.getParameterType() + "]");
  5. }

代码示例来源:origin: spring-projects/spring-framework

  1. @Override
  2. protected void handleMissingValue(String name, MethodParameter parameter, Message<?> message) {
  3. throw new MessageHandlingException(message, "Missing path template variable '" + name +
  4. "' for method parameter type [" + parameter.getParameterType() + "]");
  5. }

代码示例来源:origin: spring-projects/spring-batch

  1. /**
  2. * Launches a Batch Job using the provided request {@link Message}. The payload
  3. * of the {@link Message} <em>must</em> be an instance of {@link JobLaunchRequest}.
  4. *
  5. * @param requestMessage must not be null.
  6. * @return Generally a {@link JobExecution} will always be returned. An
  7. * exception ({@link MessageHandlingException}) will only be thrown if there
  8. * is a failure to start the job. The cause of the exception will be a
  9. * {@link JobExecutionException}.
  10. *
  11. * @throws MessageHandlingException when a job cannot be launched
  12. */
  13. @Override
  14. protected Object handleRequestMessage(Message<?> requestMessage) {
  15. Assert.notNull(requestMessage, "The provided requestMessage must not be null.");
  16. final Object payload = requestMessage.getPayload();
  17. Assert.isInstanceOf(JobLaunchRequest.class, payload, "The payload must be of type JobLaunchRequest.");
  18. final JobLaunchRequest jobLaunchRequest = (JobLaunchRequest) payload;
  19. final JobExecution jobExecution;
  20. try {
  21. jobExecution = this.jobLaunchingMessageHandler.launch(jobLaunchRequest);
  22. } catch (JobExecutionException e) {
  23. throw new MessageHandlingException(requestMessage, e);
  24. }
  25. return jobExecution;
  26. }

代码示例来源:origin: spring-projects/spring-framework

  1. new MessageHandlingException(message, "Unexpected handler method invocation error", ex);
  2. processHandlerMethodException(handlerMethod, handlingException, message);

代码示例来源:origin: spring-projects/spring-integration

  1. private MessageHandlingException wrapToMessageHandlingExceptionIfNecessary(Message<?> message, String description,
  2. Throwable cause) {
  3. if (cause instanceof MessageHandlingException) {
  4. throw (MessageHandlingException) cause;
  5. }
  6. else {
  7. throw new MessageHandlingException(message, description, cause);
  8. }
  9. }

代码示例来源:origin: org.springframework/spring-messaging

  1. @Override
  2. protected void handleMissingValue(String headerName, MethodParameter parameter, Message<?> message) {
  3. throw new MessageHandlingException(message, "Missing header '" + headerName +
  4. "' for method parameter type [" + parameter.getParameterType() + "]");
  5. }

代码示例来源:origin: org.springframework/spring-messaging

  1. @Override
  2. protected void handleMissingValue(String name, MethodParameter parameter, Message<?> message) {
  3. throw new MessageHandlingException(message, "Missing path template variable '" + name +
  4. "' for method parameter type [" + parameter.getParameterType() + "]");
  5. }

代码示例来源:origin: spring-projects/spring-integration

  1. protected TcpConnection obtainConnection(Message<?> message) {
  2. TcpConnection connection;
  3. Assert.notNull(this.clientConnectionFactory, "'clientConnectionFactory' cannot be null");
  4. try {
  5. connection = this.clientConnectionFactory.getConnection();
  6. }
  7. catch (Exception e) {
  8. logger.error("Error creating connection", e);
  9. throw new MessageHandlingException(message, "Failed to obtain a connection", e);
  10. }
  11. return connection;
  12. }

代码示例来源:origin: spring-projects/spring-integration

  1. @Override
  2. public T processMessage(Message<?> message) {
  3. try {
  4. return this.delegate.process(message);
  5. }
  6. catch (Exception e) {
  7. throw new MessageHandlingException(message, e);
  8. }
  9. }

代码示例来源:origin: spring-projects/spring-integration

  1. public void handle(Message<?> message) {
  2. throw new MessageHandlingException(message, "intentional test failure");
  3. }

代码示例来源:origin: spring-projects/spring-integration

  1. public WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer,
  2. SubProtocolHandlerRegistry protocolHandlerRegistry) {
  3. Assert.notNull(webSocketContainer, "'webSocketContainer' must not be null");
  4. Assert.notNull(protocolHandlerRegistry, "'protocolHandlerRegistry' must not be null");
  5. this.webSocketContainer = webSocketContainer;
  6. this.server = this.webSocketContainer instanceof ServerWebSocketContainer;
  7. this.subProtocolHandlerRegistry = protocolHandlerRegistry;
  8. this.subProtocolHandlerChannel = new FixedSubscriberChannel(message -> {
  9. try {
  10. handleMessageAndSend(message);
  11. }
  12. catch (Exception e) {
  13. throw new MessageHandlingException(message, e);
  14. }
  15. });
  16. }

代码示例来源:origin: spring-projects/spring-integration

  1. private Iterator<Object> messageToFileIterator(Message<?> message, Reader reader, String filePath) {
  2. BufferedReader bufferedReader = wrapToBufferedReader(message, reader);
  3. String firstLineAsHeader = null;
  4. if (this.firstLineHeaderName != null) {
  5. try {
  6. firstLineAsHeader = bufferedReader.readLine();
  7. }
  8. catch (IOException e) {
  9. throw new MessageHandlingException(message, "IOException while reading first line", e);
  10. }
  11. }
  12. return new FileIterator(message, bufferedReader, firstLineAsHeader, filePath);
  13. }

代码示例来源:origin: spring-projects/spring-integration

  1. @Override
  2. protected String put(Message<?> message, Session<FTPFile> session, String subDirectory) {
  3. try {
  4. return doInWorkingDirectory(message, session,
  5. () -> super.put(message, session, subDirectory));
  6. }
  7. catch (IOException e) {
  8. throw new MessageHandlingException(message, "Cannot handle PUT command", e);
  9. }
  10. }

代码示例来源:origin: spring-projects/spring-integration

  1. @Override
  2. protected List<String> mPut(Message<?> message, Session<FTPFile> session, File localDir) {
  3. try {
  4. return doInWorkingDirectory(message, session,
  5. () -> super.mPut(message, session, localDir));
  6. }
  7. catch (IOException e) {
  8. throw new MessageHandlingException(message, "Cannot handle MPUT command", e);
  9. }
  10. }

代码示例来源:origin: spring-projects/spring-integration

  1. @Override
  2. protected void handleMessageInternal(Message<?> message) throws Exception {
  3. Object mqttMessage = this.converter.fromMessage(message, Object.class);
  4. String topic = this.topicProcessor.processMessage(message);
  5. if (topic == null && this.defaultTopic == null) {
  6. throw new MessageHandlingException(message,
  7. "No topic could be determined from the message and no default topic defined");
  8. }
  9. publish(topic == null ? this.defaultTopic : topic, mqttMessage, message);
  10. }

代码示例来源:origin: spring-projects/spring-integration

  1. /**
  2. * Executes the script and returns the result.
  3. */
  4. @Override
  5. public final T processMessage(Message<?> message) {
  6. try {
  7. ScriptSource source = this.getScriptSource(message);
  8. Map<String, Object> variables = this.scriptVariableGenerator.generateScriptVariables(message);
  9. return this.executeScript(source, variables);
  10. }
  11. catch (Exception e) {
  12. throw new MessageHandlingException(message, "failed to execute script", e);
  13. }
  14. }

代码示例来源:origin: spring-projects/spring-integration

  1. @Bean
  2. @ServiceActivator(inputChannel = "annotatedBeanMessageHandlerChannel2")
  3. @IdempotentReceiver("idempotentReceiverInterceptor")
  4. public MessageHandler messageHandler2() {
  5. return message -> {
  6. if (message.getHeaders().containsKey(IntegrationMessageHeaderAccessor.DUPLICATE_MESSAGE)) {
  7. throw new MessageHandlingException(message, "duplicate message has been received");
  8. }
  9. };
  10. }

代码示例来源:origin: spring-projects/spring-integration

  1. public String echoWithMessagingException(String value) {
  2. throw new MessageHandlingException(new GenericMessage<String>(value));
  3. }

代码示例来源:origin: spring-projects/spring-integration

  1. private void produceConnectAckMessage(Message<?> message, SimpMessageHeaderAccessor headerAccessor) {
  2. String sessionId = headerAccessor.getSessionId();
  3. SimpMessageHeaderAccessor connectAck = SimpMessageHeaderAccessor.create(SimpMessageType.CONNECT_ACK);
  4. connectAck.setSessionId(sessionId);
  5. connectAck.setHeader(SimpMessageHeaderAccessor.CONNECT_MESSAGE_HEADER, message);
  6. Message<byte[]> ackMessage = MessageBuilder.createMessage(EMPTY_PAYLOAD, connectAck.getMessageHeaders());
  7. WebSocketSession session = this.webSocketContainer.getSession(sessionId);
  8. try {
  9. this.subProtocolHandlerRegistry.findProtocolHandler(session).handleMessageToClient(session, ackMessage);
  10. }
  11. catch (Exception e) {
  12. throw new MessageHandlingException(message, "Error sending connect ack message", e);
  13. }
  14. }

代码示例来源:origin: spring-projects/spring-integration

  1. @Test
  2. public void testExceptionTypeRouteFlow() {
  3. Message<?> failedMessage = new GenericMessage<>("foo");
  4. IllegalArgumentException rootCause = new IllegalArgumentException("bad argument");
  5. RuntimeException middleCause = new RuntimeException(rootCause);
  6. MessageHandlingException error = new MessageHandlingException(failedMessage, "failed", middleCause);
  7. ErrorMessage message = new ErrorMessage(error);
  8. this.exceptionTypeRouteFlowInput.send(message);
  9. assertNotNull(this.illegalArgumentChannel.receive(1000));
  10. assertNull(this.exceptionRouterDefaultChannel.receive(0));
  11. assertNull(this.runtimeExceptionChannel.receive(0));
  12. assertNull(this.messageHandlingExceptionChannel.receive(0));
  13. }

相关文章