本文整理了Java中org.springframework.messaging.MessageHandlingException.<init>()
方法的一些代码示例,展示了MessageHandlingException.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MessageHandlingException.<init>()
方法的具体详情如下:
包路径:org.springframework.messaging.MessageHandlingException
类名称:MessageHandlingException
方法名:<init>
暂无
代码示例来源:origin: spring-projects/spring-framework
@Override
protected void handleMissingValue(String headerName, MethodParameter parameter, Message<?> message) {
throw new MessageHandlingException(message, "Missing header '" + headerName +
"' for method parameter type [" + parameter.getParameterType() + "]");
}
代码示例来源:origin: spring-projects/spring-framework
@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() + "]");
}
代码示例来源:origin: spring-projects/spring-batch
/**
* 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;
}
代码示例来源:origin: spring-projects/spring-framework
new MessageHandlingException(message, "Unexpected handler method invocation error", ex);
processHandlerMethodException(handlerMethod, handlingException, message);
代码示例来源:origin: spring-projects/spring-integration
private MessageHandlingException wrapToMessageHandlingExceptionIfNecessary(Message<?> message, String description,
Throwable cause) {
if (cause instanceof MessageHandlingException) {
throw (MessageHandlingException) cause;
}
else {
throw new MessageHandlingException(message, description, cause);
}
}
代码示例来源:origin: org.springframework/spring-messaging
@Override
protected void handleMissingValue(String headerName, MethodParameter parameter, Message<?> message) {
throw new MessageHandlingException(message, "Missing header '" + headerName +
"' for method parameter type [" + parameter.getParameterType() + "]");
}
代码示例来源:origin: org.springframework/spring-messaging
@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() + "]");
}
代码示例来源:origin: spring-projects/spring-integration
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;
}
代码示例来源:origin: spring-projects/spring-integration
@Override
public T processMessage(Message<?> message) {
try {
return this.delegate.process(message);
}
catch (Exception e) {
throw new MessageHandlingException(message, e);
}
}
代码示例来源:origin: spring-projects/spring-integration
public void handle(Message<?> message) {
throw new MessageHandlingException(message, "intentional test failure");
}
代码示例来源:origin: spring-projects/spring-integration
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);
}
});
}
代码示例来源:origin: spring-projects/spring-integration
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);
}
代码示例来源:origin: spring-projects/spring-integration
@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);
}
}
代码示例来源:origin: spring-projects/spring-integration
@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);
}
}
代码示例来源:origin: spring-projects/spring-integration
@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);
}
代码示例来源:origin: spring-projects/spring-integration
/**
* 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);
}
}
代码示例来源:origin: spring-projects/spring-integration
@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");
}
};
}
代码示例来源:origin: spring-projects/spring-integration
public String echoWithMessagingException(String value) {
throw new MessageHandlingException(new GenericMessage<String>(value));
}
代码示例来源:origin: spring-projects/spring-integration
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);
}
}
代码示例来源:origin: spring-projects/spring-integration
@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));
}
内容来源于网络,如有侵权,请联系作者删除!