Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.Packet


     */
    public void run() {
        try {
            while (!closed.get()) {
                DatagramPacket dpacket = socket.receive();
                Packet packet = wireFormat.readPacket(channelId, dpacket);
                if (packet != null) {
                    doConsumePacket(packet);
                }
            }
            log.trace("The socket peer is now closed");
View Full Code Here


        return "EmberTransportChannel: " + client;
    }

    public void newMessage(ByteArrayServerClient client, Object msg) {
        byte[] bytes = (byte[]) msg;
        Packet packet = null;
        try {
            packet = wireFormat.fromBytes(bytes);
            doConsumePacket(packet);
        }
        catch (IOException 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

                    ThreadedExecutor exec = new ThreadedExecutor();
                    exec.execute(new Runnable() {
                        public void run() {
                            while (!closed.get()) {
                                try {
                                    Packet packet = bpq.dequeue();
                                    if (packet != null) {
                                        dispatchToClient(packet);
                                    }
                                }
                                catch (InterruptedException e) {
View Full Code Here

                socket.setSoTimeout(SO_TIMEOUT);
                while (!socket.isClosed()) {
                    socket.setSoTimeout(0);
                    socket.receive(dpacket);
                    if (dpacket.getLength() > 0) {
                        Packet packet = wireFormat.readPacket(getClientID(), dpacket);
                        if (packet != null) {
                            doConsumePacket(packet);
                        }
                    }
                }
View Full Code Here

        packet.setMemoryUsage(count);
        dataOut.write(data, 0, count);
    }

    protected synchronized final Packet readPacket(DataInput dataIn, PacketReader reader) throws IOException {
        Packet packet = reader.createPacket();
        int length = dataIn.readInt();
        packet.setMemoryUsage(length);
        // read all the remaining data in one chunk ignoring the header
        // TODO sometimes the length should exclude the header?
        byte[] data = new byte[length];
        dataIn.readFully(data);
        //then splat into the internal datainput
View Full Code Here

     * @throws IOException
     */
    public Packet readPacketFromByteArray(byte[] data) throws IOException {
        ByteArrayInputStream bytesIn = new ByteArrayInputStream(data);
        DataInputStream dataIn = new DataInputStream(bytesIn);
        Packet packet = createPacket();
        buildPacket(packet, dataIn);
        return packet;
    }
View Full Code Here

     * @return the first dequeued Packet or blocks until one is available
     * @throws JMSException
     * @throws InterruptedException
     */
    public Packet dequeue() throws JMSException, InterruptedException {
        Packet result = null;
        synchronized (outLock) {
            while ((result = dequeueNoWait()) == null) {
                outLock.wait(WAIT_TIMEOUT);
            }
        }
View Full Code Here

     * @param timeInMillis maximum time to wait to dequeue a Packet
     * @throws JMSException
     * @throws InterruptedException
     */
    public Packet dequeue(long timeInMillis) throws JMSException, InterruptedException {
        Packet result = dequeueNoWait();
        if (result == null) {
            synchronized (outLock) {
                outLock.wait(timeInMillis);
                result = dequeueNoWait();
            }
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.