Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.Packet


    public void testRemovePacketById(){
        int size = 100;
        MemoryBoundedQueue queue = queueManager.getMemoryBoundedQueue(QUEUE_NAME);
        List list = new ArrayList(size);
        for (int i = 0;i < size;i++) {
            Packet p = new Receipt();
            p.setId(""+i);
            list.add(p);
            queue.enqueue(p);
        }
        for (int i =0; i < size; i++){
            Packet p = (Packet)list.get(i);
            Packet removed = queue.remove(p.getId());
            assertTrue(removed != null);
            assertTrue(removed == p);
        }
        assertTrue(queue.size() == 0);
        queue.close();
View Full Code Here


        }

        public void run() {
            while (internalCount < localCount) {
                try {
                    Packet obj = queue.dequeue();
                    if (obj != null) {
                        count.increment();
                        internalCount++;
                        if (count.get() == TOTAL_LOAD) {
                            synchronized (mutex) {
View Full Code Here

    public void testRpc() throws Exception {
        rpcTest = true;

        List tmpList = (List) packets.clone();
        for (int i = 0; i < TEST_SIZE; i++) {
            Packet packet = (Packet) tmpList.get(i);
            Receipt receipt = sender.send(packet, 4000);
            assertTrue("Receipt should not be null!", receipt != null);
            System.out.println("Got receipt: " + receipt + " for packet: " + packet);
        }
View Full Code Here

        sender.setClientID("sender");
        sender.start();

        packets = new ArrayList(TEST_SIZE);
        for (int i = 0; i < TEST_SIZE; i++) {
            Packet test = new ActiveMQMessage();
            test.setId("test:" + i);
            packets.add(test);
        }
    }
View Full Code Here

                    log.trace("The socket peer is now closed");
                    stop();
                    return;
                }
                else if (answer != null) {
                    Packet packet = (Packet) answer;
                    // we might have just got a packet in but we've already shut down
                    if (closed.get()) {
                        break;
                    }
                    doConsumePacket(packet);
View Full Code Here

                    ThreadedExecutor exec = new ThreadedExecutor();
                    exec.execute(new Runnable() {
                        public void run() {
                            while (!closed.get()) {
                                try {
                                    Packet packet = bpq.dequeue();
                                }
                                catch (InterruptedException e) {
                                    log.warn("async dispatch got an interupt", e);
                                }
                                catch (JMSException e) {
View Full Code Here

            byte type = is.readByte();
            if (type != PACKET_RECORD_TYPE) {
                throw new IOException("Record is not a packet type.");
            }
            String destination = is.readUTF();
            Packet packet = wireFormat.readPacket(is);
            is.close();
            return packet;

        }
        catch (InvalidRecordLocationException e) {
View Full Code Here

        while ((pos = journal.getNextRecordLocation(pos)) != null) {
            byte[] data = journal.read(pos);

            // Read the destination and packate from the record.
            String destination = null;
            Packet packet = null;
            DataInputStream is = new DataInputStream(new ByteArrayInputStream(data));
            try {
                byte type = is.readByte();
                switch (type) {
                    case PACKET_RECORD_TYPE:
View Full Code Here

    }

    private void dispatch(UpPacket p) {
        try {
            // Dont dispatch messages until the channel is started..
            Packet packet = toPacket(p);
            log.trace("<<<< SENDING UP <<<< " + packet);
            if (packet != null) {
                doConsumePacket(packet);
            }
        }
View Full Code Here

    protected void readPacket(LogRecord logRecord, QueueMessageContainer container) {
        if (!logRecord.isCTRL() && !logRecord.isEOB() && logRecord.length > 0) {
            try {
                // TODO for some wierd reason we get an unnecessary long which I'm guessing is the size
                Packet packet = wireFormat.fromBytes(logRecord.data, 2, logRecord.length - 2);
                if (packet instanceof ActiveMQMessage) {
                    container.addMessage((ActiveMQMessage) packet);
                }
                else if (packet instanceof MessageAck) {
                    MessageAck ack = (MessageAck) packet;
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.message.Packet

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.