Examples of ActiveMQBytesMessage


Examples of org.apache.activemq.command.ActiveMQBytesMessage

                            throw new IOException("Received an unexpected message: expected ID: " + (nextSequenceId - 1) + " but was: " + producerSequenceId + " for message: " + m);
                        }
                    }

                    // Read the buffer in.
                    ActiveMQBytesMessage bm = (ActiveMQBytesMessage)m;
                    buffer = new byte[(int)bm.getBodyLength()];
                    bm.readBytes(buffer);
                    pos = 0;
                    if (jmsProperties == null) {
                        jmsProperties = Collections.unmodifiableMap(new HashMap<String, Object>(bm.getProperties()));
                    }
                } else {
                    eosReached = true;
                    if (jmsProperties == null) {
                        // no properties found
View Full Code Here

Examples of org.apache.activemq.command.ActiveMQBytesMessage

            addItem(CompositeDataConstants.BODY_PREVIEW, "Body preview", new ArrayType(1, SimpleType.BYTE));
        }

        @Override
        public Map<String, Object> getFields(Object o) throws OpenDataException {
            ActiveMQBytesMessage m = (ActiveMQBytesMessage)o;
            m.setReadOnlyBody(true);
            Map<String, Object> rc = super.getFields(o);
            long length = 0;
            try {
                length = m.getBodyLength();
                rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(length));
            } catch (JMSException e) {
                rc.put(CompositeDataConstants.BODY_LENGTH, Long.valueOf(0));
            }
            try {
                byte preview[] = new byte[(int)Math.min(length, 255)];
                m.readBytes(preview);

                // This is whack! Java 1.5 JMX spec does not support primitive
                // arrays!
                // In 1.6 it seems it is supported.. but until then...
                Byte data[] = new Byte[preview.length];
View Full Code Here

Examples of org.apache.activemq.command.ActiveMQBytesMessage

    public ActiveMQMessage convertFrame(StompFrame command) throws JMSException, ProtocolException {
        final Map headers = command.getHeaders();
        final ActiveMQMessage msg;
        if (headers.containsKey(Stomp.Headers.CONTENT_LENGTH)) {
            headers.remove(Stomp.Headers.CONTENT_LENGTH);
            ActiveMQBytesMessage bm = new ActiveMQBytesMessage();
            bm.writeBytes(command.getContent());
            msg = bm;
        } else {
            ActiveMQTextMessage text = new ActiveMQTextMessage();
            try {
                text.setText(new String(command.getContent(), "UTF-8"));
View Full Code Here

Examples of org.apache.activemq.command.ActiveMQBytesMessage

            ActiveMQTextMessage msg = (ActiveMQTextMessage)message.copy();
            command.setContent(msg.getText().getBytes("UTF-8"));

        } else if( message.getDataStructureType() == ActiveMQBytesMessage.DATA_STRUCTURE_TYPE ) {

          ActiveMQBytesMessage msg = (ActiveMQBytesMessage)message.copy();
          msg.setReadOnlyBody(true);
            byte[] data = new byte[(int)msg.getBodyLength()];
            msg.readBytes(data);

            headers.put(Stomp.Headers.CONTENT_LENGTH, ""+data.length);
            command.setContent(data);
        }
        return command;
View Full Code Here

Examples of org.apache.activemq.command.ActiveMQBytesMessage

            addItem("BodyLength", "Body length", SimpleType.LONG);
            addItem("BodyPreview", "Body preview", new ArrayType(1,SimpleType.BYTE));
        }

        public Map getFields(Object o) throws OpenDataException {
            ActiveMQBytesMessage m = (ActiveMQBytesMessage) o;
            Map rc = super.getFields(o);
            long length=0;
            try {
                length = m.getBodyLength();
                rc.put("BodyLength", new Long(length));
            } catch (JMSException e) {
                rc.put("BodyLength", new Long(0));
            }
            try {
                byte preview[] = new byte[ (int)Math.min(length, 255) ];
                m.readBytes(preview);
               
                // This is whack!  Java 1.5 JMX spec does not support primitive arrays!
                // In 1.6 it seems it is supported.. but until then...
                Byte data[] = new Byte[ preview.length ];
                for (int i = 0; i < data.length; i++) {
View Full Code Here

Examples of org.apache.activemq.command.ActiveMQBytesMessage

   
    /**
     * Tests transforming messages into ActiveMQ's message implementation.
     */
    public void testTransformMessage() throws Exception {
      assertTrue("Transforming a BytesMessage message into an ActiveMQBytesMessage",ActiveMQMessageTransformation.transformMessage((BytesMessage)new ActiveMQBytesMessage(), null) instanceof ActiveMQBytesMessage);
     
      assertTrue("Transforming a MapMessage message to an ActiveMQMapMessage",ActiveMQMessageTransformation.transformMessage((MapMessage)new ActiveMQMapMessage(), null) instanceof ActiveMQMapMessage);
     
      assertTrue("Transforming an ObjectMessage message to an ActiveMQObjectMessage",ActiveMQMessageTransformation.transformMessage((ObjectMessage)new ActiveMQObjectMessage(), null) instanceof ActiveMQObjectMessage);
     
View Full Code Here

Examples of org.apache.activemq.command.ActiveMQBytesMessage

    public ActiveMQBytesMessageTest(String arg0) {
        super(arg0);
    }

    public void testGetDataStructureType() {
        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
        assertEquals(msg.getDataStructureType(), CommandTypes.ACTIVEMQ_BYTES_MESSAGE);
    }
View Full Code Here

Examples of org.apache.activemq.command.ActiveMQBytesMessage

        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
        assertEquals(msg.getDataStructureType(), CommandTypes.ACTIVEMQ_BYTES_MESSAGE);
    }

    public void testGetBodyLength() {
        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
        int len = 10;
        try {
            for (int i = 0; i < len; i++) {
                msg.writeLong(5l);
            }
        } catch (JMSException ex) {
            ex.printStackTrace();
        }
        try {
            msg.reset();
            assertTrue(msg.getBodyLength() == (len * 8));
        } catch (Throwable e) {
            e.printStackTrace();
            assertTrue(false);
        }
    }
View Full Code Here

Examples of org.apache.activemq.command.ActiveMQBytesMessage

            assertTrue(false);
        }
    }

    public void testReadBoolean() {
        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
        try {
            msg.writeBoolean(true);
            msg.reset();
            assertTrue(msg.readBoolean());
        } catch (JMSException jmsEx) {
            jmsEx.printStackTrace();
            assertTrue(false);
        }
    }
View Full Code Here

Examples of org.apache.activemq.command.ActiveMQBytesMessage

            assertTrue(false);
        }
    }

    public void testReadByte() {
        ActiveMQBytesMessage msg = new ActiveMQBytesMessage();
        try {
            msg.writeByte((byte) 2);
            msg.reset();
            assertTrue(msg.readByte() == 2);
        } catch (JMSException jmsEx) {
            jmsEx.printStackTrace();
            assertTrue(false);
        }
    }
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.