List of usage examples for org.springframework.messaging MessageHandlingException MessageHandlingException
public MessageHandlingException(Message<?> failedMessage, Throwable cause)
From source file:ch.rasc.wampspring.method.WampSessionMethodArgumentResolver.java
@Override public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception { WampSession wampSession = ((WampMessage) message).getWampSession(); if (wampSession == null) { throw new MessageHandlingException(message, "No \"wampSession\" header in message"); }//from ww w.j a v a 2 s. c o m return wampSession; }
From source file:ch.rasc.wampspring.method.PrincipalMethodArgumentResolver.java
@Override public Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception { Principal user = ((WampMessage) message).getPrincipal(); if (user == null) { throw new MessageHandlingException(message, "No \"principal\" header in message"); }//from w ww . j a va2s.c o m return user; }
From source file:org.springframework.cloud.stream.app.gpfdist.sink.GpfdistMessageHandler.java
@Override protected void doWrite(Message<?> message) throws Exception { Object payload = message.getPayload(); if (payload instanceof String) { String data = (String) payload; if (delimiter != null) { processor.onNext(Buffer.wrap(data + delimiter)); } else {/* w w w .j av a2s .c o m*/ processor.onNext(Buffer.wrap(data)); } if (meter != null) { if ((meterCount++ % rateInterval) == 0) { meter.mark(rateInterval); log.info("METER: 1 minute rate = " + meter.getOneMinuteRate() + " mean rate = " + meter.getMeanRate()); } } } else { throw new MessageHandlingException(message, "message not a String"); } }
From source file:org.springframework.integration.handler.LambdaMessageProcessor.java
@Override public Object processMessage(Message<?> message) { Object[] args = buildArgs(message); try {/*from www . ja va2 s. c om*/ return this.method.invoke(this.target, args); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof ClassCastException) { logger.error( "Could not invoke the method due to a class cast exception, if using a lambda in the DSL, " + "consider using an overloaded EIP method that takes a Class<?> argument to explicitly " + "specify the type. An example of when this often occurs is if the lambda is configured to " + "receive a Message<?> argument.", e.getCause()); } throw new MessageHandlingException(message, e.getCause()); } catch (Exception e) { throw new MessageHandlingException(message, e); } }
From source file:org.springframework.integration.jms.JmsOutboundGateway.java
@Override protected Object handleRequestMessage(final Message<?> requestMessage) { if (!this.initialized) { afterPropertiesSet();/*from ww w. j ava2s . c om*/ } try { Object reply; if (this.replyContainer == null) { reply = sendAndReceiveWithoutContainer(requestMessage); } else { if (this.idleReplyContainerTimeout > 0) { synchronized (this.lifeCycleMonitor) { this.lastSend = System.currentTimeMillis(); if (!this.replyContainer.isRunning()) { if (logger.isDebugEnabled()) { logger.debug(this.getComponentName() + ": Starting reply container."); } this.replyContainer.start(); this.idleTask = getTaskScheduler().scheduleAtFixedRate(new IdleContainerStopper(), this.idleReplyContainerTimeout / 2); } } } reply = this.sendAndReceiveWithContainer(requestMessage); } if (reply == null) { if (this.requiresReply) { throw new MessageTimeoutException(requestMessage, "failed to receive JMS response within timeout of: " + this.receiveTimeout + "ms"); } else { return null; } } if (reply instanceof javax.jms.Message) { return buildReply((javax.jms.Message) reply); } else { return reply; } } catch (JMSException e) { throw new MessageHandlingException(requestMessage, e); } }
From source file:org.springframework.messaging.handler.annotation.reactive.HeaderMethodArgumentResolver.java
@Override protected void handleMissingValue(String headerName, MethodParameter parameter, Message<?> message) { throw new MessageHandlingException(message, "Missing header '" + headerName + "' for method parameter type [" + parameter.getParameterType() + "]"); }
From source file:org.springframework.xd.integration.hadoop.outbound.HdfsDataStoreMessageHandler.java
@Override protected void doWrite(Message<?> message) throws Exception { Assert.notNull(storeWriter, "Writer already closed"); Object payload = message.getPayload(); if (payload instanceof String) { storeWriter.write((String) payload); } else {/*from w w w .j a va 2 s .c om*/ throw new MessageHandlingException(message, "message not a String"); } }
From source file:org.springframework.xd.integration.hadoop.outbound.HdfsPartitionDataStoreMessageHandler.java
@Override protected void doWrite(Message<?> message) throws Exception { Assert.notNull(storePartitionWriter, "Writer already closed"); Object payload = message.getPayload(); if (payload instanceof String) { storePartitionWriter.write((String) payload, message); } else {//from w w w .j a va 2 s .co m throw new MessageHandlingException(message, "message not a String"); } }
From source file:org.springframework.xd.reactor.MultipleBroadcasterMessageHandler.java
@Override protected void handleMessageInternal(Message<?> message) { Broadcaster<Object> broadcasterToUse = getBroadcaster(message); if (ClassUtils.isAssignable(inputType.getRawClass(), message.getClass())) { broadcasterToUse.onNext(message); } else if (ClassUtils.isAssignable(inputType.getRawClass(), message.getPayload().getClass())) { broadcasterToUse.onNext(message.getPayload()); } else {//from w ww .ja va 2s . c o m throw new MessageHandlingException(message, "Processor signature does not match [" + message.getClass() + "] or [" + message.getPayload().getClass() + "]"); } if (logger.isDebugEnabled()) { Object idToUse = partitionExpression.getValue(evaluationContext, message, Object.class); Control controls = this.controlsMap.get(idToUse); if (controls != null) { logger.debug(controls.debug()); } } }
From source file:org.springframework.xd.rxjava.MultipleSubjectMessageHandler.java
@Override protected void handleMessageInternal(Message<?> message) throws Exception { Subject subjectToUse = getSubject(message); if (ClassUtils.isAssignable(inputType.getRawClass(), message.getClass())) { subjectToUse.onNext(message);/*www . jav a 2s.c o m*/ } else if (ClassUtils.isAssignable(inputType.getRawClass(), message.getPayload().getClass())) { subjectToUse.onNext(message.getPayload()); } else { throw new MessageHandlingException(message, "Processor signature does not match [" + message.getClass() + "] or [" + message.getPayload().getClass() + "]"); } }