Package org.activeio.adapter

Examples of org.activeio.adapter.PacketByteArrayOutputStream


    public Packet writePacket(Packet packet, DataOutput dataOut) throws IOException {
       
        PacketWriter writer = getWriter(packet);
        if (writer != null) {
           
            PacketByteArrayOutputStream internalBytesOut = new PacketByteArrayOutputStream( 50+ (packet.getMemoryUsage()==0 ? 1024 : packet.getMemoryUsage()) );
            DataOutputStream internalDataOut = new DataOutputStream(internalBytesOut);           
            writer.writePacket(packet, internalDataOut);
            internalDataOut.close();
           
            org.activeio.Packet p = internalBytesOut.getPacket();
            int count = p.remaining();

            dataOut.writeByte(packet.getPacketType());
            dataOut.writeInt(count);
            packet.setMemoryUsage(count);
View Full Code Here


     * @throws JMSException
     */
    public RecordLocation writePacket(String destination, Packet packet, boolean sync) throws JMSException {
        try {

            PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(pos);
            os.writeByte(PACKET_RECORD_TYPE);
            os.writeUTF(destination);
            wireFormat.writePacket(packet, os);
            os.close();
            return journal.write(pos.getPacket(), sync);
        }
        catch (IOException e) {
            throw createWriteException(packet, e);
        }
    }
View Full Code Here

     * @throws JMSException
     */
    public RecordLocation writeCommand(String command, boolean sync) throws JMSException {
        try {

            PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(pos);
            os.writeByte(COMMAND_RECORD_TYPE);
            os.writeUTF(command);
            os.close();
            return journal.write(pos.getPacket(), sync);

        }
        catch (IOException e) {
            throw createWriteException(command, e);
        }
View Full Code Here

     * @return
     */
    public RecordLocation writeTxCommand(TxCommand command, boolean sync) throws XAException {
        try {

            PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(pos);
            os.writeByte(TX_COMMAND_RECORD_TYPE);
            os.writeByte(command.getType());
            os.writeBoolean(command.getWasPrepared());
            switch(command.getType()) {
              case TxCommand.LOCAL_COMMIT:
              case TxCommand.LOCAL_ROLLBACK:
                  os.writeUTF( (String) command.getTransactionId() );
                  break;
              default:
                  ActiveMQXid xid = (ActiveMQXid) command.getTransactionId();
                xid.write(os);
                break;
            }
            os.close();
            return journal.write(pos.getPacket(), sync);
        }
        catch (IOException e) {
            throw createWriteException(command, e);
        }
    }
View Full Code Here

     * @return
     */
    public RecordLocation writePacket(String destinationName, String subscription, MessageIdentity messageIdentity, boolean sync) throws JMSException{
        try {

            PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(pos);
            os.writeByte(ACK_RECORD_TYPE);
            os.writeUTF(destinationName);
            os.writeUTF(subscription);
            os.writeUTF(messageIdentity.getMessageID());
            os.close();
            return journal.write(pos.getPacket(), sync);

        }
        catch (IOException e) {
            throw createWriteException("Ack for message: "+messageIdentity, e);
        }
View Full Code Here

        long start = System.currentTimeMillis();
        for (int i = 0; i < MESSAGE_COUNT; i++) {

            message.setJMSMessageID("id:"+i);

            PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(pos);
            os.writeByte(1);
            os.writeUTF("Test");
            wireFormat.writePacket(message, os);
            os.close();
View Full Code Here

                copy.setReceiptRequired(false);
               
                for (int i = 0; i < MESSAGE_COUNT; i++) {
                    copy.setJMSMessageID("id:"+i);

                    PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
                    DataOutputStream os = new DataOutputStream(pos);
                    os.writeByte(1);
                    os.writeUTF("Test");
                    wireFormat.writePacket(copy, os);
                    os.close();
View Full Code Here

        long start = System.currentTimeMillis();
        for (int i = 0; i < MESSAGE_COUNT; i++) {

            message.setJMSMessageID("id:"+i);

            PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(pos);
            os.writeByte(1);
            os.writeUTF("Test");
            wireFormat.writePacket(message, os);
            os.close();
View Full Code Here

                copy.setReceiptRequired(false);
               
                for (int i = 0; i < MESSAGE_COUNT; i++) {
                    copy.setJMSMessageID("id:"+i);

                    PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
                    DataOutputStream os = new DataOutputStream(pos);
                    os.writeByte(1);
                    os.writeUTF("Test");
                    wireFormat.writePacket(copy, os);
                    os.close();
View Full Code Here

     * @throws JMSException
     */
    public RecordLocation writePacket(String destination, Packet packet, boolean sync) throws JMSException {
        try {

            PacketByteArrayOutputStream pos = new PacketByteArrayOutputStream();
            DataOutputStream os = new DataOutputStream(pos);
            os.writeByte(PACKET_RECORD_TYPE);
            os.writeUTF(destination);
            os.close();
            org.activeio.Packet p = wireFormat.writePacket(packet, pos);
View Full Code Here

TOP

Related Classes of org.activeio.adapter.PacketByteArrayOutputStream

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.