@Override default ProcessingType getProcessingType() { if (getReturnDataType().isStreamType() || getSourceDataTypes().stream().anyMatch(dataType -> dataType.isStreamType())) { return IO_RW; } else { return CPU_INTENSIVE; } }
@Override default ProcessingType getProcessingType() { if (getReturnDataType().isStreamType() || getSourceDataTypes().stream().anyMatch(dataType -> dataType.isStreamType())) { return IO_RW; } else { return CPU_LITE; } }
private boolean scheduleIoRwEvent(CoreEvent event) { return event.getMessage().getPayload().getDataType().isStreamType() && event.getMessage().getPayload().getLength().orElse(MAX_VALUE) > STREAM_PAYLOAD_BLOCKING_IO_THRESHOLD; }
/** * Validates that the payload is not consumable so it can be copied. * * If validation fails then throws a MessagingException * * @param message * @throws MuleException if the payload is consumable */ public static void validateMessageIsNotConsumable(Message message) { if (message.getPayload().getDataType().isStreamType()) { throw new MuleRuntimeException(cannotCopyStreamPayload(message.getPayload().getDataType().getType().getName())); } }
Object payload = muleMessage.getPayload().getValue(); if (muleMessage.getPayload().getDataType().isStreamType()) { addInfo(PAYLOAD_INFO_KEY, abbreviate(payload.toString(), 1000)); } else {
/** * Obtains a {@link String} representation of the message payload for logging without throwing exception. If encoding is * required it will use the encoding set on the message. * <p> * If the existing payload is consumable (i.e. can't be read twice) or an exception occurs during transformation then the an * exception won't be thrown but rather a description of the payload type will be returned. * * @return message payload as a String or message with the payload type if payload can't be converted to a String */ public String getPayloadForLogging(Message message, Charset encoding) { DataType dataType = message.getPayload().getDataType(); if (!dataType.isStreamType()) { try { return getPayload(message, DataType.STRING, encoding); } catch (MessageTransformerException e) { return "Payload could not be converted to a String. Payload type is " + dataType.getType(); } } return "Payload is a stream of type: " + dataType.getType(); }
@Override public Object transformMessage(DataType outputType, MuleContext muleContext) throws MessageTransformerException { if (outputType == null) { throw new MessageTransformerException(objectIsNull("outputType"), null, message); } Message transformedMessage = muleContext.getTransformationService().transform(message, outputType); if (message.getPayload().getDataType().isStreamType()) { setMessage(transformedMessage); } return transformedMessage.getPayload().getValue(); }
/** * Returns the message contents for logging * * @param encoding the encoding to use when converting bytes to a string, if necessary * @param muleContext the Mule node. * @return the message contents as a string * @throws MuleException if the message cannot be converted into a string */ @Override public String getMessageAsString(Charset encoding, MuleContext muleContext) throws MuleException { try { Message transformedMessage = muleContext.getTransformationService() .transform(message, DataType.builder().type(String.class).charset(encoding).build()); if (message.getPayload().getDataType().isStreamType()) { setMessage(transformedMessage); } return (String) transformedMessage.getPayload().getValue(); } catch (Exception e) { throw new DefaultMuleException(cannotReadPayloadAsString(message.getClass().getName()), e); } }