Package javax.jms

Examples of javax.jms.BytesMessage.reset()


        } else {
            ActiveMQMessage activeMessage = null;

            if (message instanceof BytesMessage) {
                BytesMessage bytesMsg = (BytesMessage) message;
                bytesMsg.reset();
                ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
                msg.setConnection(connection);
                try {
                    for (;;) {
                        // Reads a byte from the message stream until the stream
View Full Code Here


      long bodyLength = m2.getBodyLength();

      assertEquals(161, bodyLength);

      m2.reset();

      // test the unsigned reads

      m2.readBoolean();
      int unsignedByte = m2.readUnsignedByte();
View Full Code Here

      catch (MessageNotReadableException e)
      {
         // OK
      }

      m2.reset();

      assertEquals(0, m2.getBodyLength());

      //Test that changing the received message doesn't affect the sent message
      m.reset();
View Full Code Here

      bm.writeFloat(9.0f);
      bm.writeInt(10);
      bm.writeLong(11l);
      bm.writeShort((short)12);
      bm.writeUTF("this is an UTF String");
      bm.reset();
   }

   protected void assertEquivalent(Message m, int mode) throws JMSException
   {
      super.assertEquivalent(m, mode);
View Full Code Here

        byte[] bytesArray = new byte[]{1, 2};
        BytesMessage message = (BytesMessage) JmsMessageUtils.toMessage(bytesArray, session);

        // Makes the message readable
        message.reset();
        byte[] bytesArrayResult = new byte[(int) message.getBodyLength()];
        int length = message.readBytes(bytesArrayResult);
        assertEquals(2, length);
        assertEquals(bytesArray[0], bytesArrayResult[0]);
        assertEquals(bytesArray[1], bytesArrayResult[1]);
View Full Code Here

        Object result2 = trans.transform(compressedBytes);
        assertTrue("Transformed object should be a Bytes message", result2 instanceof BytesMessage);

        // 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));
View Full Code Here

    public static byte[] toByteArray(Message message, String jmsSpec, String encoding) throws JMSException, IOException
    {
        if (message instanceof BytesMessage)
        {
            BytesMessage bMsg = (BytesMessage) message;
            bMsg.reset();

            if (JmsConstants.JMS_SPECIFICATION_11.equals(jmsSpec))
            {
                long bmBodyLength = bMsg.getBodyLength();
                if (bmBodyLength > Integer.MAX_VALUE)
View Full Code Here

         foreignBytesMessage.writeByte((byte)i);
      }

      JBossBytesMessage copy = new JBossBytesMessage(foreignBytesMessage, 0);

      foreignBytesMessage.reset();
      copy.reset();

      ensureEquivalent(foreignBytesMessage, copy);
   }
View Full Code Here

     * @return the body of the message
     * @throws JMSException for any JMS error
     */
    protected Object getBody(Message message) throws JMSException {
        BytesMessage bytes = (BytesMessage) message;
        bytes.reset();
        long length = bytes.getBodyLength();
        if (length > Integer.MAX_VALUE) {
            throw new JMSException("Can't handle BytesMessage, JMSMessageID="
                                   + message.getJMSMessageID()
                                   + ", length=" + length
View Full Code Here

                            ((TextMessage) message).getText());
                        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);
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.