Package org.apache.activemq.command

Examples of org.apache.activemq.command.ActiveMQBytesMessage


   
    /**
     * @return a new object instance
     */
    public DataStructure createObject() {
        return new ActiveMQBytesMessage();
    }
View Full Code Here


   
    /**
     * @return a new object instance
     */
    public DataStructure createObject() {
        return new ActiveMQBytesMessage();
    }
View Full Code Here

   
    /**
     * @return a new object instance
     */
    public DataStructure createObject() {
        return new ActiveMQBytesMessage();
    }
View Full Code Here

    public ActiveMQMessage convertFrame(ProtocolConverter converter, 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

            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

     * @return the an ActiveMQBytesMessage
     * @throws JMSException if the JMS provider fails to create this message due
     *                 to some internal error.
     */
    public BytesMessage createBytesMessage() throws JMSException {
        ActiveMQBytesMessage message = new ActiveMQBytesMessage();
        configureMessage(message);
        return message;
    }
View Full Code Here

        BytesMessage test = localSession.createBytesMessage();
        test.writeBytes(bytes);
        producer.send(test);
        Message msg = consumer1.receive(RECEIVE_TIMEOUT_MILLS);
        assertNotNull(msg);
        ActiveMQBytesMessage message = (ActiveMQBytesMessage) msg;
        assertTrue(message.isCompressed());
        assertTrue(message.getContent().getLength() < bytes.length);

        byte[] result = new byte[bytes.length];
        assertEquals(bytes.length, message.readBytes(result));
        assertEquals(-1, message.readBytes(result));

        for(int i = 0; i < bytes.length; ++i) {
            assertEquals(bytes[i], result[i]);
        }
    }
View Full Code Here

        assertEquals(extractText(queue.browse()[0]), extractText(queue.browse()[0]));
    }

    @Test
    public void testBrowseByteMessageFails() throws Exception {
        ActiveMQBytesMessage bm = new ActiveMQBytesMessage();
        bm.writeBytes("123456".getBytes());
        Object result = OpenTypeSupport.convert(bm);
        LOG.info("result : " + result);
    }
View Full Code Here

            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);
                m.reset();

                // 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

     * @return the an ActiveMQBytesMessage
     * @throws JMSException if the JMS provider fails to create this message due
     *                 to some internal error.
     */
    public BytesMessage createBytesMessage() throws JMSException {
        ActiveMQBytesMessage message = new ActiveMQBytesMessage();
        configureMessage(message);
        return message;
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.command.ActiveMQBytesMessage

Copyright © 2018 www.massapicom. 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.