Package org.apache.activemq.util

Examples of org.apache.activemq.util.ByteSequence


        final LastRecovered lastRecovered = subscriberLastRecoveredMap.get(key);       
        try {
            JDBCMessageRecoveryListener jdbcListener = new JDBCMessageRecoveryListener() {
                public boolean recoverMessage(long sequenceId, byte[] data) throws Exception {
                    if (listener.hasSpace()) {
                        Message msg = (Message) wireFormat.unmarshal(new ByteSequence(data));
                        msg.getMessageId().setBrokerSequenceId(sequenceId);
                        if (listener.recoverMessage(msg)) {
                            lastRecovered.update(sequenceId, msg);
                            return true;
                        }
View Full Code Here


            query.setParameter(1, destinationName);
            query.setParameter(2, lastMessageId.get());
            query.setMaxResults(maxReturned);
            int count = 0;
            for (StoredMessage m : (List<StoredMessage>)query.getResultList()) {
                Message message = (Message)wireFormat.unmarshal(new ByteSequence(m.getData()));
                listener.recoverMessage(message);
                lastMessageId.set(m.getId());
                count++;
                if (count >= maxReturned) {
                    return;
View Full Code Here

            Query query = manager.createQuery("select m from StoredMessage m where m.destination=?1 and m.id>?2 order by m.id asc");
            query.setParameter(1, destinationName);
            query.setParameter(2, ss.getLastAckedId());
            for (StoredMessage m : (List<StoredMessage>)query.getResultList()) {
                Message message = (Message)wireFormat.unmarshal(new ByteSequence(m.getData()));
                listener.recoverMessage(message);
            }
        } catch (Throwable e) {
            adapter.rollbackEntityManager(null, manager);
            throw IOExceptionSupport.create(e);
View Full Code Here

        ActiveMQTextMessage msg = new ActiveMQTextMessage();
        String str = "testText";
        msg.setText(str);
        msg.beforeMarshall(null);
       
        ByteSequence bytes = msg.getContent();
        msg = new ActiveMQTextMessage();
        msg.setContent(bytes);
       
        assertEquals(msg.getText(), str);
    }
View Full Code Here

            // Bummer.. Both checks are screwed. we don't know
            // if any of the two buffer are ok. This should
            // only happen is data got corrupted.
            throw new IOException("Control data corrupted.");
        }
        return new ByteSequence(data, 0, data.length);
    }
View Full Code Here

        answer.setCacheEnabled(cacheEnabled);
        return answer;
    }

    protected Object marshalAndUnmarshall(Object original, WireFormat wireFormat) throws IOException {
        ByteSequence packet = wireFormat.marshal(original);
        return wireFormat.unmarshal(packet);
    }
View Full Code Here

        }
    }

    protected void assertByteSequencesEqual(String message, ByteSequence expected, Object actualValue) {
        assertTrue(message + ". Actual value should be a ByteSequence but was: " + actualValue, actualValue instanceof ByteSequence);
        ByteSequence actual = (ByteSequence)actualValue;
        int length = expected.getLength();
        assertEquals(message + ". Length", length, actual.getLength());
        int offset = expected.getOffset();
        assertEquals(message + ". Offset", offset, actual.getOffset());
        byte[] data = expected.getData();
        byte[] actualData = actual.getData();
        for (int i = 0; i < length; i++) {
            assertEquals(message + ". Offset " + i, data[offset + i], actualData[offset + i]);
        }
    }
View Full Code Here

        resultEndpoint.assertIsSatisfied();

        List<Exchange> list = resultEndpoint.getReceivedExchanges();
        Exchange exchange = list.get(0);
        ByteSequence body = (ByteSequence)exchange.getIn().getBody();
        body.compact(); // trims the byte array to the actual size.
        assertEquals("body", new String(payload), new String(body.data));
    }
View Full Code Here

        started = true;
        preferedFileLength=Math.max(PREFERED_DIFF, getMaxFileLength()-PREFERED_DIFF);
        lock();

        ByteSequence sequence = controlFile.load();
        if (sequence != null && sequence.getLength() > 0) {
            unmarshallState(sequence);
        }
        if (useNio) {
            appender = new NIODataFileAppender(this);
        } else {
View Full Code Here

        } else {
            dos.writeBoolean(false);
        }

        byte[] bs = baos.toByteArray();
        return new ByteSequence(bs, 0, bs.length);
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.util.ByteSequence

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.