Package org.codehaus.activemq.util

Examples of org.codehaus.activemq.util.BitArray


        msg.setJMSClientID(super.readUTF(dataIn));
        msg.setProducerID(super.readUTF(dataIn));
        msg.setJMSDestination(ActiveMQDestination.readFromStream(dataIn));
        msg.setJMSDeliveryMode(dataIn.readByte());
        msg.setJMSPriority(dataIn.readByte());
        BitArray ba = msg.getBitArray();
    
        msg.setJMSRedelivered(ba.get(ActiveMQMessage.REDELIVERED_INDEX));
        msg.setXaTransacted(ba.get(ActiveMQMessage.XA_TRANS_INDEX));

        if (ba.get(ActiveMQMessage.CORRELATION_INDEX)) {
            msg.setJMSCorrelationID(super.readUTF(dataIn));
        }
        if (ba.get(ActiveMQMessage.TYPE_INDEX)) {
            msg.setJMSType(super.readUTF(dataIn));
        }
        if (ba.get(ActiveMQMessage.BROKER_NAME_INDEX)) {
            msg.setEntryBrokerName(super.readUTF(dataIn));
        }
        if (ba.get(ActiveMQMessage.CLUSTER_NAME_INDEX)) {
            msg.setEntryClusterName(super.readUTF(dataIn));
        }
        if (ba.get(ActiveMQMessage.TRANSACTION_ID_INDEX)) {
            msg.setTransactionId(super.readUTF(dataIn));
        }
        if (ba.get(ActiveMQMessage.REPLY_TO_INDEX)) {
            msg.setJMSReplyTo(ActiveMQDestination.readFromStream(dataIn));
        }
        if (ba.get(ActiveMQMessage.TIMESTAMP_INDEX)) {
            msg.setJMSTimestamp(dataIn.readLong());
        }
        if (ba.get(ActiveMQMessage.EXPIRATION_INDEX)) {
            msg.setJMSExpiration(dataIn.readLong());
        }
        if (ba.get(ActiveMQMessage.CID_INDEX)) {
            int cidlength = dataIn.readShort();
            if (cidlength > 0) {
                int[] cids = new int[cidlength];
                for (int i = 0; i < cids.length; i++) {
                    cids[i] = dataIn.readShort();
                }
                msg.setConsumerNos(cids);
            }
        }
        if (ba.get(ActiveMQMessage.PROPERTIES_INDEX)) {
            msg.setProperties(msg.readMapProperties(dataIn));
        }
        if (ba.get(ActiveMQMessage.PAYLOAD_INDEX)) {
            int payloadLength = dataIn.readInt();
            if (payloadLength >= 0) {
                byte[] payload = new byte[payloadLength];
                dataIn.readFully(payload);
                msg.setBodyAsBytes(payload);
View Full Code Here


     * @throws IOException
     */
    public void buildPacket(Packet p, DataInput dataIn) throws IOException {
        AbstractPacket packet = (AbstractPacket)p;
        packet.setId(readUTF(dataIn));
        BitArray ba = packet.getBitArray();
        ba.readFromStream(dataIn);
        packet.setReceiptRequired(ba.get(AbstractPacket.RECEIPT_REQUIRED_INDEX));
        if (ba.get(AbstractPacket.BROKERS_VISITED_INDEX)){
            int visitedLen = dataIn.readShort();
            for (int i =0; i < visitedLen; i++){
                packet.addBrokerVisited(dataIn.readUTF());
            }       
        }
View Full Code Here

        MessageAck ack = (MessageAck) packet;
        ack.setConsumerId(dataIn.readUTF());
        ack.setMessageID(dataIn.readUTF());
        ack.setTransactionId(dataIn.readUTF());
       
        BitArray ba = new BitArray();
        ba.readFromStream(dataIn);
        ack.setMessageRead(ba.get(MessageAck.MESSAGE_READ_INDEX));
        ack.setXaTransacted(ba.get(MessageAck.XA_TRANSACTED_INDEX));
        ack.setPersistent(ba.get(MessageAck.PERSISTENT_INDEX));
        ack.setDestination(ActiveMQDestination.readFromStream(dataIn));
    }
View Full Code Here

    private transient int memoryUsageReferenceCount;

    private CopyOnWriteArraySet brokersVisited;
  
    protected AbstractPacket(){
        this.bitArray = new BitArray();
    }
View Full Code Here

        MessageAck ack = (MessageAck) packet;
        super.writeUTF(ack.getConsumerId(), dataOut);
        super.writeUTF(ack.getMessageID(), dataOut);
        super.writeUTF(ack.getTransactionId(), dataOut);
       
        BitArray ba = new BitArray();
        ba.set(MessageAck.MESSAGE_READ_INDEX, ack.isMessageRead());
        ba.set(MessageAck.XA_TRANSACTED_INDEX, ack.isXaTransacted());
        ba.set(MessageAck.PERSISTENT_INDEX,ack.isPersistent());
        ba.writeToStream(dataOut);
       
        ActiveMQDestination.writeToStream((ActiveMQDestination) ack.getDestination(), dataOut);
    }
View Full Code Here

     * @throws IOException thrown if an error occurs
     */
    public void writePacket(Packet p, DataOutput dataOut) throws IOException {
        AbstractPacket packet = (AbstractPacket)p;
        writeUTF(packet.getId(), dataOut);
        BitArray ba = packet.getBitArray();
        ba.set(AbstractPacket.RECEIPT_REQUIRED_INDEX, packet.isReceiptRequired());
        Object[] visited = packet.getBrokersVisited();
        boolean writeVisited = visited != null && visited.length > 0;
        ba.set(AbstractPacket.BROKERS_VISITED_INDEX,writeVisited);
        ba.writeToStream(dataOut);
        if (writeVisited){
            dataOut.writeShort(visited.length);
            for(int i =0; i < visited.length; i++){
                dataOut.writeUTF(visited[i].toString());
            }
View Full Code Here

     */
    public void writePacket(Packet packet, DataOutput dataOut) throws IOException {
        ActiveMQMessage msg = (ActiveMQMessage) packet;
        byte[] payload = msg.getBodyAsBytes();
       
        BitArray ba = msg.getBitArray();
        ba.reset();
       
        ba.set(ActiveMQMessage.CORRELATION_INDEX, msg.getJMSCorrelationID() != null);
        ba.set(ActiveMQMessage.TYPE_INDEX, msg.getJMSType() != null);
        ba.set(ActiveMQMessage.BROKER_NAME_INDEX, msg.getEntryBrokerName() != null);
        ba.set(ActiveMQMessage.CLUSTER_NAME_INDEX, msg.getEntryClusterName() != null);
        ba.set(ActiveMQMessage.TRANSACTION_ID_INDEX, msg.getTransactionId() != null);
        ba.set(ActiveMQMessage.REPLY_TO_INDEX, msg.getJMSReplyTo() != null);
        ba.set(ActiveMQMessage.TIMESTAMP_INDEX, msg.getJMSTimestamp() > 0);
        ba.set(ActiveMQMessage.EXPIRATION_INDEX, msg.getJMSExpiration() > 0);
        ba.set(ActiveMQMessage.REDELIVERED_INDEX, msg.getJMSRedelivered());
        ba.set(ActiveMQMessage.XA_TRANS_INDEX, msg.isXaTransacted());
        ba.set(ActiveMQMessage.CID_INDEX, msg.getConsumerNos() != null);
        ba.set(ActiveMQMessage.PROPERTIES_INDEX, msg.getProperties() != null && msg.getProperties().size() > 0);
        ba.set(ActiveMQMessage.PAYLOAD_INDEX, payload != null);
       
        super.writePacket(msg, dataOut);
       
        super.writeUTF(msg.getJMSClientID(), dataOut);
        super.writeUTF(msg.getProducerID(), dataOut);
        ActiveMQDestination.writeToStream((ActiveMQDestination) msg.getJMSDestination(), dataOut);
        dataOut.write(msg.getJMSDeliveryMode());
        dataOut.write(msg.getJMSPriority());

       

        if (ba.get(ActiveMQMessage.CORRELATION_INDEX)) {
            super.writeUTF(msg.getJMSCorrelationID(), dataOut);
        }
        if (ba.get(ActiveMQMessage.TYPE_INDEX)) {
            super.writeUTF(msg.getJMSType(), dataOut);
        }
        if (ba.get(ActiveMQMessage.BROKER_NAME_INDEX)) {
            super.writeUTF(msg.getEntryBrokerName(), dataOut);
        }
        if (ba.get(ActiveMQMessage.CLUSTER_NAME_INDEX)) {
            super.writeUTF(msg.getEntryClusterName(), dataOut);
        }
        if (ba.get(ActiveMQMessage.TRANSACTION_ID_INDEX)) {
            super.writeUTF(msg.getTransactionId(), dataOut);
        }
        if (ba.get(ActiveMQMessage.REPLY_TO_INDEX)) {
            ActiveMQDestination.writeToStream((ActiveMQDestination) msg.getJMSReplyTo(), dataOut);
        }
        if (ba.get(ActiveMQMessage.TIMESTAMP_INDEX)) {
            dataOut.writeLong(msg.getJMSTimestamp());
        }
        if (ba.get(ActiveMQMessage.EXPIRATION_INDEX)) {
            dataOut.writeLong(msg.getJMSExpiration());
        }
        if (ba.get(ActiveMQMessage.CID_INDEX)) {
            //write out consumer numbers ...
            int[] cids = msg.getConsumerNos();
            dataOut.writeShort(cids.length);
            for (int i = 0; i < cids.length; i++) {
                dataOut.writeShort(cids[i]);
            }
        }
        if (ba.get(ActiveMQMessage.PROPERTIES_INDEX)) {
            msg.writeMapProperties(msg.getProperties(), dataOut);
        }
        if (ba.get(ActiveMQMessage.PAYLOAD_INDEX)) {
            dataOut.writeInt(payload.length);
            dataOut.write(payload);
        }
    }
View Full Code Here

        boolean longSequence = ack.getSequenceNumber() > Integer.MAX_VALUE;
       
      
        Object[] visited = ack.getBrokersVisited();
        boolean writeVisited = visited != null && visited.length > 0;
        BitArray ba = ack.getBitArray();
        ba.reset();
        ba.set(AbstractPacket.RECEIPT_REQUIRED_INDEX, ack.isReceiptRequired());
        ba.set(AbstractPacket.BROKERS_VISITED_INDEX,writeVisited);
        ba.set(MessageAck.MESSAGE_READ_INDEX, ack.isMessageRead());
        ba.set(MessageAck.TRANSACTION_ID_INDEX, ack.isPartOfTransaction());
        ba.set(MessageAck.XA_TRANS_INDEX, ack.isXaTransacted());
        ba.set(MessageAck.PERSISTENT_INDEX,ack.isPersistent());
        ba.set(MessageAck.EXPIRED_INDEX,ack.isExpired());
        ba.set(MessageAck.EXTERNAL_MESSAGE_ID_INDEX, ack.isExternalMessageId());
        ba.set(MessageAck.CACHED_VALUES_INDEX,cachingEnabled);
        ba.set(MessageAck.LONG_SEQUENCE_INDEX, longSequence);
        ba.writeToStream(dataOut);
       
        if (ack.isReceiptRequired()){
            dataOut.writeShort(ack.getId());
        }
        if (ack.isExternalMessageId()){
View Full Code Here

     * @throws IOException
     */
    public void buildPacket(Packet p, DataInput dataIn) throws IOException {
        AbstractPacket packet = (AbstractPacket) p;
        packet.setId(dataIn.readShort());
        BitArray ba = packet.getBitArray();
        ba.readFromStream(dataIn);
        packet.setReceiptRequired(ba.get(AbstractPacket.RECEIPT_REQUIRED_INDEX));
        if (ba.get(AbstractPacket.BROKERS_VISITED_INDEX)) {
            int visitedLen = dataIn.readShort();
            for (int i = 0;i < visitedLen;i++) {
                packet.addBrokerVisited(dataIn.readUTF());
            }
        }
View Full Code Here

     * @param dataIn the data input stream to build the packet from
     * @throws IOException
     */
    public void buildPacket(Packet packet, DataInput dataIn) throws IOException {
        MessageAck ack = (MessageAck) packet;
        BitArray ba = ack.getBitArray();
        ba.readFromStream(dataIn);
        boolean cachingEnabled = ba.get(MessageAck.CACHED_VALUES_INDEX);
        ack.setMessageRead(ba.get(MessageAck.MESSAGE_READ_INDEX));
        ack.setPersistent(ba.get(MessageAck.PERSISTENT_INDEX));
        ack.setExpired(ba.get(MessageAck.EXPIRED_INDEX));
        if (ba.get(AbstractPacket.RECEIPT_REQUIRED_INDEX)) {
            ack.setReceiptRequired(true);
            ack.setId(dataIn.readShort());
        }
        if (ba.get(MessageAck.EXTERNAL_MESSAGE_ID_INDEX)) {
            ack.setExternalMessageId(true);
            ack.setMessageID(dataIn.readUTF());
        }
        else {
            if (cachingEnabled) {
                short key = dataIn.readShort();
                ack.setProducerKey((String) wireFormat.getValueFromReadCache(key));
            }
            else {
                ack.setProducerKey(dataIn.readUTF());
            }
            if (ba.get(MessageAck.LONG_SEQUENCE_INDEX)) {
                ack.setSequenceNumber(dataIn.readLong());
            }
            else {
                ack.setSequenceNumber(dataIn.readInt());
            }
        }
        if (ba.get(AbstractPacket.BROKERS_VISITED_INDEX)) {
            int visitedLen = dataIn.readShort();
            for (int i = 0;i < visitedLen;i++) {
                ack.addBrokerVisited(dataIn.readUTF());
            }
        }
        if (ba.get(MessageAck.TRANSACTION_ID_INDEX)) {
            if (cachingEnabled) {
                short key = dataIn.readShort();
                ack.setTransactionId(wireFormat.getValueFromReadCache(key));
            } else {
                if (ba.get(MessageAck.XA_TRANS_INDEX)) {
                    ack.setTransactionId(ActiveMQXid.read(dataIn));
                }
                else {
                    ack.setTransactionId(super.readUTF(dataIn));
                }
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.util.BitArray

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.