@Converter public static InputStream soapMessageToInputStream(final SOAPMessage soapMessage, Exchange exchange) throws SOAPException, IOException { CachedOutputStream cos = new CachedOutputStream(exchange); soapMessage.writeTo(cos); InputStream in = cos.getInputStream(); return in; }
LOG.debug("Streaming response in non-chunked mode with content-length {} and buffer size: {}", len, len); copyStream(stream.getInputStream(), os, len);
protected Object createByteArrayFromBytesMessage(Exchange exchange, BytesMessage message) throws JMSException { // ActiveMQ has special optimised mode for bytes message, so we should use streaming if possible Long size = getSafeLongProperty(message, "_AMQ_LARGE_SIZE"); if (size != null && size > 0) { LOG.trace("Optimised for Artemis: Reading from BytesMessage in streaming mode directly into CachedOutputStream payload"); CachedOutputStream cos = new CachedOutputStream(exchange, true); // this will save the stream and wait until the entire message is written before continuing. message.setObjectProperty("JMS_AMQ_SaveStream", cos); try { // and then lets get the input stream of this so we can read it return cos.getInputStream(); } catch (IOException e) { JMSException cause = new MessageFormatException(e.getMessage()); cause.initCause(e); throw cause; } finally { IOHelper.close(cos); } } if (message.getBodyLength() > Integer.MAX_VALUE) { LOG.warn("Length of BytesMessage is too long: {}", message.getBodyLength()); return null; } byte[] result = new byte[(int)message.getBodyLength()]; message.readBytes(result); return result; }