Package org.codehaus.activemq.util

Examples of org.codehaus.activemq.util.BitArray


     * @throws IOException
     */
    public void buildPacket(Packet packet, DataInput dataIn) throws IOException {
        ActiveMQMessage msg = (ActiveMQMessage) packet;
        msg.setId(readUTF(dataIn));
        BitArray ba = msg.getBitArray();
        ba.readFromStream(dataIn);
        msg.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++){
                msg.addBrokerVisited(dataIn.readUTF());
            }       
        }
        msg.setJMSClientID(super.readUTF(dataIn));
        msg.setProducerID(super.readUTF(dataIn));
        msg.setJMSDestination(ActiveMQDestination.readFromStream(dataIn));
        msg.setJMSDeliveryMode(dataIn.readByte());
        msg.setJMSPriority(dataIn.readByte());
    
        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.DISPATCHED_FROM_DLQ_INDEX)){
            msg.setDispatchedFromDLQ(true);
        }
        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));
        if (wireFormatVersion >= 2){
            ack.setExpired(ba.get(MessageAck.EXPIRED_INDEX));
        }
    }
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());
        if (wireFormatVersion >= 2){
            ba.set(MessageAck.EXPIRED_INDEX,ack.isExpired());
        }
        ba.writeToStream(dataOut);
       
        ActiveMQDestination.writeToStream((ActiveMQDestination) ack.getDestination(), dataOut);
    }
View Full Code Here

    private transient int memoryUsageReferenceCount;

    private CopyOnWriteArraySet brokersVisited;
  
    protected AbstractPacket(){
        this.bitArray = new BitArray();
    }
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();
        writeUTF(msg.getId(),dataOut);
        ba.set(AbstractPacket.RECEIPT_REQUIRED_INDEX, packet.isReceiptRequired());
        Object[] visited = msg.getBrokersVisited();
        boolean writeVisited = visited != null && visited.length > 0;
        ba.set(AbstractPacket.BROKERS_VISITED_INDEX,writeVisited);
        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.DISPATCHED_FROM_DLQ_INDEX,msg.isDispatchedFromDLQ());
        ba.set(ActiveMQMessage.PAYLOAD_INDEX, payload != null);
       
        ba.writeToStream(dataOut);
        if (writeVisited){
            dataOut.writeShort(visited.length);
            for(int i =0; i < visited.length; i++){
                dataOut.writeUTF(visited[i].toString());
            }
        }
      
        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);
        }
       
        if (wireFormatVersion >= 2){
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.