public final void handleMessage(Message<?> message) { Assert.notNull(message == null, "Message must not be null"); Assert.notNull(message.getPayload(), "Message payload must not be null"); if (this.logger.isDebugEnabled()) { this.logger.debug(this + " received message: " + message); } try { this.handleMessageInternal(message); } catch (Exception e) { if (e instanceof MessagingException) { throw (MessagingException) e; } throw new MessageHandlingException(message, "error occurred in message handler [" + this + "]", e); } }
@Override protected void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) { try { Object result = this.invoker.invokeMethod(message); if (result != null) { replyHolder.set(result); } } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new MessageHandlingException(message, "failure occurred in Service Activator '" + this + "'", e); } }
@Override public final void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) { if (!(message.getPayload() instanceof Serializable)) { throw new MessageHandlingException(message, this.getClass().getName() + " expects a Serializable payload type " + "but encountered [" + message.getPayload().getClass().getName() + "]"); } Message<?> requestMessage = MessageBuilder.fromMessage(message).build(); try { Message<?> reply = this.handlerProxy.handle(requestMessage); if (reply != null) { replyHolder.set(reply); } } catch (RemoteAccessException e) { throw new MessageHandlingException(message, "unable to handle message remotely", e); } }
public Object invokeMethod(Message<?> message) { Assert.notNull(message, "message must not be null"); if (message.getPayload() == null) { if (logger.isDebugEnabled()) { logger.debug("received null payload"); } return null; } Method method = this.methodResolver.resolveHandlerMethod(message); Object[] args = null; try { args = this.createArgumentArrayFromMessage(method, message); return this.doInvokeMethod(method, args, message); } catch (InvocationTargetException e) { if (e.getCause() != null && e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } throw new MessageHandlingException(message, "method '" + method + "' threw an Exception.", e.getCause()); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new MessageHandlingException(message, "Failed to invoke method '" + method + "' with arguments: " + ObjectUtils.nullSafeToString(args), e); } }
public boolean send(Message<?> message, long timeout) { Object replyChannelHeader = message.getHeaders().getReplyChannel(); if (replyChannelHeader == null) { throw new MessageHandlingException(message, "no replyChannel header available"); } MessageChannel replyChannel = null; if (replyChannelHeader instanceof MessageChannel) { replyChannel = (MessageChannel) replyChannelHeader; } else if (replyChannelHeader instanceof String) { Assert.notNull(getChannelResolver(), "ChannelResolver is required"); replyChannel = getChannelResolver().resolveChannelName((String) replyChannelHeader); } else { throw new MessageHandlingException(message, "invalid replyChannel type [" + replyChannelHeader.getClass() + "]"); } return (timeout >= 0) ? replyChannel.send(message, timeout) : replyChannel.send(message); } }
/** * write the content of Message to the cloud storage with handlers that * convert the message payload to Blob. * * @param message */ public void handleMessage(Message<?> message) { Assert.notNull(message, "message must not be null"); Assert.notNull(message.getPayload(), "message payload must not be null"); Object payload = message.getPayload(); String blobName = blobNameBuilder.createBlobName(message); LOG.debug("Message to send '{}' with name '{}'", message, blobName); if ((payload instanceof File)) { template.send(containerName, blobName, (File) payload); } else if (payload instanceof String) { template.send(containerName, blobName, (String) payload); } else { throw new MessageHandlingException(message, "unsupported Message payload type [" + payload.getClass().getName() + "]"); } }
@Override protected final void handleMessageInternal(Message<?> message) { if (!this.initialized) { this.afterPropertiesSet(); } Object correlationKey = this.correlationStrategy.getCorrelationKey(message); if (correlationKey == null) { throw new MessageHandlingException(message, this.getClass().getSimpleName() + " requires the 'correlationKey' property"); } if (this.trackedCorrelationIds != null && this.trackedCorrelationIds.contains(correlationKey)) { if (logger.isDebugEnabled()) { logger.debug("Handling of Message group with correlationKey '" + correlationKey + "' has already completed or timed out."); } this.discardMessage(message); } else { this.processMessage(message, correlationKey); } }
if (foundFallbackCandidate) { throw new MessageHandlingException(message, "Failed to resolve ambiguity " + "amongst multiple non-annotated candidates for matching Message headers.", e); throw new MessageHandlingException(message, "unable to resolve method for args: " + StringUtils.arrayToCommaDelimitedString(args));
Object value = message.getHeaders().get(headerName); if (value == null && headerAnnotation.required()) { throw new MessageHandlingException(message, "required header '" + headerName + "' not available");
/** * Writes single element and notifies {@link IMessageRegistry} instance. * @param processId * @param message */ protected void writeSingle(final String processId, final Message<?> message) { try { if (message==null) { log.warn("nothing to write for process " + processId); return; } if (msgIdThreadLocal!=null) { msgIdThreadLocal.set( (String) message.getHeaders().get(MessageRegistryConstants.MSG_HEADER_ID)); } singleElementWriterNode.store(message.getPayload(), (ProcessContext) message.getHeaders().get( MessageRegistryConstants.MSG_HEADER_CTX)); messageRegistry.consume(processId, (String) message.getHeaders().get( MessageRegistryConstants.MSG_HEADER_ID)); } catch (final Exception e) { throw new MessageHandlingException(message, e); } }
for (Object key : attributesToSet.keySet()) { if (!(key instanceof String)) { throw new MessageHandlingException(message, "Map returned from a Transformer method must have String-typed keys");
@Override protected final void handleMessageInternal(Message<?> message) { ReplyMessageHolder replyMessageHolder = new ReplyMessageHolder(); this.handleRequestMessage(message, replyMessageHolder); if (replyMessageHolder.isEmpty()) { if (this.requiresReply) { throw new MessageHandlingException(message, "handler '" + this + "' requires a reply, but no reply was received"); } if (logger.isDebugEnabled()) { logger.debug("handler '" + this + "' produced no reply for request Message: " + message); } return; } MessageChannel replyChannel = this.resolveReplyChannel(message); MessageHeaders requestHeaders = message.getHeaders(); for (MessageBuilder<?> builder : replyMessageHolder.builders()) { builder.copyHeadersIfAbsent(requestHeaders); Message<?> replyMessage = builder.build(); if (!this.sendReplyMessage(replyMessage, replyChannel)) { throw new MessageDeliveryException(replyMessage, "failed to send reply Message"); } } }
(String) message.getHeaders().get(MessageRegistryConstants.MSG_HEADER_ID), e); message.getPayload().gatherException(e); throw new MessageHandlingException(message, (Throwable)null); log.error("exception occurred while waiting!", e); message.getPayload().gatherException(e); throw new MessageHandlingException(message, (Throwable)null); log.error("exception occurred while consuming message in MR", e); message.getPayload().gatherException(e); throw new MessageHandlingException(message, (Throwable)null); log.error("exception occurred while consuming message in MR", e); message.getPayload().gatherException(e); throw new MessageHandlingException(message, (Throwable)null); throw new MessageHandlingException(message, aggregExc); throw new MessageHandlingException(message, aggregExc); (String) message.getHeaders().get(MessageRegistryConstants.MSG_HEADER_ID), e); message.getPayload().gatherException(e); throw new MessageHandlingException(message, (Throwable)null); throw new MessageHandlingException(message, (Throwable)null); throw new MessageHandlingException(message, (Throwable)null); (String) message.getHeaders().get(MessageRegistryConstants.MSG_HEADER_ID), e);