Package javax.jms

Examples of javax.jms.BytesMessage.readBytes()


        // check whether the BytesMessage contains the compressed bytes
        BytesMessage intermediate = (BytesMessage) result2;
        intermediate.reset();
        byte[] intermediateBytes = new byte[(int) (intermediate.getBodyLength())];
        int intermediateSize = intermediate.readBytes(intermediateBytes);
        assertTrue("Intermediate bytes must be compressed", compressor.isCompressed(intermediateBytes));
        assertTrue("Intermediate bytes must be equal to compressed source", Arrays.equals(compressedBytes,
            intermediateBytes));
        assertEquals("Intermediate bytes and compressed source must have same size", compressedBytes.length,
            intermediateSize);
View Full Code Here


                }

                if (bmBodyLength > 0)
                {
                    byte[] bytes = new byte[(int) bmBodyLength];
                    bMsg.readBytes(bytes);
                    return bytes;
                }
                else
                {
                    return ArrayUtils.EMPTY_BYTE_ARRAY;
View Full Code Here

            {
                ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
                byte[] buffer = new byte[4096];
                int len;

                while ((len = bMsg.readBytes(buffer)) != -1)
                {
                    baos.write(buffer, 0, len);
                }

                if (baos.size() > 0)
View Full Code Here

                                   + message.getJMSMessageID()
                                   + ", length=" + length
                                   + " - message too large ");
        }
        byte[] result = new byte[(int) length];
        if (bytes.readBytes(result) != result.length) {
            throw new JMSException("Failed to read BytesMessage");
        }
        return result;
    }
View Full Code Here

        if (inMessage instanceof TextMessage) {
            msgData = ((TextMessage)inMessage).getText().getBytes();
        } else if (inMessage instanceof BytesMessage) {
            BytesMessage bytesMessage = (BytesMessage)inMessage;
            msgData = new byte[(int)bytesMessage.getBodyLength()];
            bytesMessage.readBytes(msgData);
        } else {
            throw new JMSException("Unsupported JMS message type of " + inMessage.getClass().getName());
        }
        ByteArrayInputStream in = new ByteArrayInputStream(msgData);
        StAXOMBuilder builder = new StAXOMBuilder(in);
View Full Code Here

            if (message instanceof BytesMessage) {
                byte[] buffer = new byte[8 * 1024];
                ByteArrayOutputStream out = new ByteArrayOutputStream();

                BytesMessage byteMsg = (BytesMessage) message;
                for (int bytesRead = byteMsg.readBytes(buffer); bytesRead != -1;
                     bytesRead = byteMsg.readBytes(buffer)) {
                    out.write(buffer, 0, bytesRead);
                }
                return new ByteArrayInputStream(out.toByteArray());

View Full Code Here

                byte[] buffer = new byte[8 * 1024];
                ByteArrayOutputStream out = new ByteArrayOutputStream();

                BytesMessage byteMsg = (BytesMessage) message;
                for (int bytesRead = byteMsg.readBytes(buffer); bytesRead != -1;
                     bytesRead = byteMsg.readBytes(buffer)) {
                    out.write(buffer, 0, bytesRead);
                }
                return new ByteArrayInputStream(out.toByteArray());

            } else if (message instanceof TextMessage) {
View Full Code Here

                        wrapper.addChild(textData);
                    } else if (message instanceof BytesMessage) {
                        BytesMessage bm = (BytesMessage) message;
                        byte[] msgBytes = new byte[(int) bm.getBodyLength()];
                        bm.reset();
                        bm.readBytes(msgBytes);
                        DataHandler dataHandler = new DataHandler(
                            new ByteArrayDataSource(msgBytes));
                        OMText textData = soapFactory.createOMText(dataHandler, true);
                        wrapper.addChild(textData);
                        msgContext.setDoingMTOM(true);
View Full Code Here

            brMsg.setMsgType(BridgeMsg.TYPE_BYTES);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            byte[] buf = new byte[8192];
            BytesMessage bMsg = (BytesMessage) jMsg;
            for(;;) {
                int amount = bMsg.readBytes(buf);
                if (amount <= 0)
                    break;
                out.write(buf, 0, amount);
                if (amount < buf.length)
                    break;
View Full Code Here

            brMsg.setMsgType(BridgeMsg.TYPE_BYTES);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            byte[] buf = new byte[8192];
            BytesMessage bMsg = (BytesMessage) jMsg;
            for(;;) {
                int amount = bMsg.readBytes(buf);
                if (amount <= 0)
                    break;
                out.write(buf, 0, amount);
                if (amount < buf.length)
                    break;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.