Package javax.jms

Examples of javax.jms.BytesMessage.readBytes()


        if (length > Integer.MAX_VALUE) {
          throw new JMSException("Unable to process message " + "of size "
              + length);
        }
        byte[] body = new byte[(int)length];
        int count = bytesMessage.readBytes(body);
        if(count != length) {
          throw new JMSException("Unable to read full message. " +
              "Read " + count + " of total " + length);
        }
        event.setBody(body);
View Full Code Here


                byte[] respBytes = null;
                if(response != null)
                {
                    byte[] buffer = new byte[8 * 1024];
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    for(int bytesRead = response.readBytes(buffer);
                        bytesRead != -1; bytesRead = response.readBytes(buffer))
                    {
                        out.write(buffer, 0, bytesRead);
                    }
                    respBytes = out.toByteArray();
View Full Code Here

                if(response != null)
                {
                    byte[] buffer = new byte[8 * 1024];
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    for(int bytesRead = response.readBytes(buffer);
                        bytesRead != -1; bytesRead = response.readBytes(buffer))
                    {
                        out.write(buffer, 0, bytesRead);
                    }
                    respBytes = out.toByteArray();
                }
View Full Code Here

                    if (bytesMessage.getBodyLength() > Integer.MAX_VALUE) {
                        LOGGER.warn("Length of BytesMessage is too long: {}", bytesMessage.getBodyLength());
                        return null;
                    }
                    byte[] result = new byte[(int) bytesMessage.getBodyLength()];
                    bytesMessage.readBytes(result);
                    bodyMessage.setHeader(JMS_MESSAGE_TYPE, JmsMessageType.Bytes);
                    bodyMessage.setBody(result);
                    break;
                case Map:
                    Map<String, Object> body = new HashMap<String, Object>();
View Full Code Here

            BytesMessage sourceBytes = BytesMessage.class.cast(jmsMessage);
            if (sourceBytes.getBodyLength() > Integer.MAX_VALUE) {
                throw JCAMessages.MESSAGES.theSizeOfMessageContentExceedsBytesThatIsNotSupportedByThisMessageComposer("" + Integer.MAX_VALUE);
            }
            byte[] bytearr = new byte[(int)sourceBytes.getBodyLength()];
            sourceBytes.readBytes(bytearr);
            syMessage.setContent(bytearr);

        } else if (jmsMessage instanceof MapMessage) {
            MapMessage sourceMap = MapMessage.class.cast(jmsMessage);
            Map<String,Object> body = new HashMap<String,Object>();
View Full Code Here

            BytesMessage sourceBytes = BytesMessage.class.cast(content);
            if (sourceBytes.getBodyLength() > Integer.MAX_VALUE) {
                throw JCAMessages.MESSAGES.theSizeOfMessageContentExceedsBytesThatIsNotSupportedByThisOperationSelector("" + Integer.MAX_VALUE);
            }
            byte[] bytearr = new byte[(int)sourceBytes.getBodyLength()];
            sourceBytes.readBytes(bytearr);
            return new String(bytearr);

        } else if (content instanceof ObjectMessage) {
            ObjectMessage sourceObj = ObjectMessage.class.cast(content);
            return String.class.cast(sourceObj.getObject());
View Full Code Here

        BytesMessage bsMsg = (BytesMessage)msg;
        if (bsMsg.getBodyLength() >= Integer.MAX_VALUE) {
            Assert.fail("Message body is too large[" + bsMsg.getBodyLength() + "]: extract it manually.");
        }
        byte[] ba = new byte[(int)bsMsg.getBodyLength()];
        bsMsg.readBytes(ba);
        return ba;
    }
    /**
     * Reads the body of a JMS {@link Message} as a String.
     * @param msg the JMS {@link Message}.
View Full Code Here

        byte[] body = new byte[1024];
        int size = 0;
        int n;
        try
        {
            while ((n = msg.readBytes(buf)) > 0)
            {
                body = ensure(size + n, body, size);
                System.arraycopy(buf, 0, body, size, n);
                size += n;
            }
View Full Code Here

        byte[] body;
        try
        {
          body = new byte[(int) m.getBodyLength ()];
          m.readBytes (body);
          assertTrue (new String (body).equals ("hello"));
        }
        catch ( JMSException e )
        {
          assertTrue (false);
View Full Code Here

        byte[] body;
        try
        {
          body = new byte[(int) m.getBodyLength ()];
          m.readBytes (body);
          assertTrue (new String (body).equals ("hello"));

          MessageProducer replyProducer = session.createProducer (m.getJMSReplyTo ());
          replyProducer.send (m);
        }
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.