List of usage examples for org.springframework.messaging Message getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.springframework.integration.history.MessageHistory.java
@SuppressWarnings("unchecked") public static <T> Message<T> write(Message<T> message, NamedComponent component, MessageBuilderFactory messageBuilderFactory) { Assert.notNull(message, "Message must not be null"); Assert.notNull(component, "Component must not be null"); Properties metadata = extractMetadata(component); if (!metadata.isEmpty()) { MessageHistory previousHistory = message.getHeaders().get(HEADER_NAME, MessageHistory.class); List<Properties> components = (previousHistory != null) ? new ArrayList<Properties>(previousHistory) : new ArrayList<Properties>(); components.add(metadata);// w w w. j a v a 2 s .c om MessageHistory history = new MessageHistory(components); if (message instanceof MutableMessage) { message.getHeaders().put(HEADER_NAME, history); } else if (message instanceof ErrorMessage) { IntegrationMessageHeaderAccessor headerAccessor = new IntegrationMessageHeaderAccessor(message); headerAccessor.setHeader(HEADER_NAME, history); Throwable payload = ((ErrorMessage) message).getPayload(); ErrorMessage errorMessage = new ErrorMessage(payload, headerAccessor.toMessageHeaders()); message = (Message<T>) errorMessage; } else if (message instanceof AdviceMessage) { IntegrationMessageHeaderAccessor headerAccessor = new IntegrationMessageHeaderAccessor(message); headerAccessor.setHeader(HEADER_NAME, history); message = new AdviceMessage<T>(message.getPayload(), headerAccessor.toMessageHeaders(), ((AdviceMessage<?>) message).getInputMessage()); } else { if (!(message instanceof GenericMessage) && (messageBuilderFactory instanceof DefaultMessageBuilderFactory || messageBuilderFactory instanceof MutableMessageBuilderFactory)) { if (logger.isWarnEnabled()) { logger.warn("MessageHistory rebuilds the message and produces the result of the [" + messageBuilderFactory + "], not an instance of the provided type [" + message.getClass() + "]. Consider to supply a custom MessageBuilderFactory " + "to retain custom messages during MessageHistory tracking."); } } message = messageBuilderFactory.fromMessage(message).setHeader(HEADER_NAME, history).build(); } } return message; }
From source file:org.springframework.xd.reactor.BroadcasterMessageHandler.java
@Override protected void handleMessageInternal(Message<?> message) throws Exception { if (ClassUtils.isAssignable(inputType.getRawClass(), message.getClass())) { stream.onNext(message);/* ww w. j a va 2s . c o m*/ } else if (ClassUtils.isAssignable(inputType.getRawClass(), message.getPayload().getClass())) { //TODO handle type conversion of payload to input type if possible stream.onNext(message.getPayload()); } if (logger.isDebugEnabled()) { logger.debug(control.debug()); } }
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 {/* www.j av a 2 s . 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.reactor.SynchronousDispatcherMessageHandler.java
@Override protected void handleMessageInternal(Message<?> message) throws Exception { if (ClassUtils.isAssignable(inputType.getRawClass(), message.getClass())) { stream.onNext(message);/*from ww w .j a va2 s . com*/ } else if (ClassUtils.isAssignable(inputType.getRawClass(), message.getPayload().getClass())) { //TODO handle type conversion of payload to input type if possible stream.onNext(message.getPayload()); } if (logger.isDebugEnabled()) { logger.debug(consume.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);/*from w w w. j a v a 2 s . c om*/ } 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() + "]"); } }
From source file:org.springframework.xd.rxjava.SubjectMessageHandler.java
@Override protected void handleMessageInternal(Message<?> message) throws Exception { if (ClassUtils.isAssignable(inputType.getRawClass(), message.getClass())) { subject.onNext(message);/*w ww. j a va 2 s. co m*/ } else if (ClassUtils.isAssignable(inputType.getRawClass(), message.getPayload().getClass())) { subject.onNext(message.getPayload()); } else { throw new MessageHandlingException(message, "Processor signature does not match [" + message.getClass() + "] or [" + message.getPayload().getClass() + "]"); } }