Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.TransactionInfo


     * @throws IOException
     */

    public void buildPacket(Packet packet, DataInput dataIn) throws IOException {
        super.buildPacket(packet, dataIn);
        TransactionInfo info = (TransactionInfo) packet;
        info.setTransactionId(dataIn.readUTF());
        info.setType(dataIn.readByte());
        info.setReceiptRequired(dataIn.readBoolean());
    }
View Full Code Here


     * @throws IOException thrown if an error occurs
     */

    public void writePacket(Packet packet, DataOutput dataOut) throws IOException {
        super.writePacket(packet, dataOut);
        TransactionInfo info = (TransactionInfo) packet;
        super.writeUTF(info.getTransactionId(), dataOut);
        dataOut.writeByte(info.getType());
        dataOut.writeBoolean(info.isReceiptRequired());
    }
View Full Code Here

        TransactionInfoReader reader = new TransactionInfoReader();
        assertTrue(reader.getPacketType() == Packet.TRANSACTION_INFO);
    }

    public void testReadPacket() {
        TransactionInfo info = (TransactionInfo) createPacket();

        TransactionInfoWriter writer = new TransactionInfoWriter();
        TransactionInfoReader reader = new TransactionInfoReader();
        try {
            byte[] data = writer.writePacketToByteArray(info);
            TransactionInfo testInfo = (TransactionInfo) reader.readPacketFromByteArray(data);

            assertPacket(testInfo, info);
        }
        catch (Throwable e) {
            e.printStackTrace();
View Full Code Here

            assertTrue(false);
        }
    }

    public void testTime() {
        TransactionInfo info = (TransactionInfo) createPacket();

        TransactionInfoWriter writer = new TransactionInfoWriter();
        TransactionInfoReader reader = new TransactionInfoReader();
        TransactionInfo testInfo = null;
        try {
            int count = 100000;
            long startTime = System.currentTimeMillis();
            for (int i = 0; i < count; i++) {
                byte[] data = writer.writePacketToByteArray(info);
View Full Code Here

            assertTrue(false);
        }
    }

    protected void assertValidPacket(Packet packet) {
        TransactionInfo testInfo = (TransactionInfo) packet;
        assertTrue(testInfo.getId().equals(this.TransactionId));
        assertTrue(testInfo.getType() == this.type);
    }
View Full Code Here

        assertTrue(testInfo.getId().equals(this.TransactionId));
        assertTrue(testInfo.getType() == this.type);
    }

    protected Packet createPacket() {
        TransactionInfo info = new TransactionInfo();
        info.setId(this.TransactionId);
        info.setType(this.type);
        return info;
    }
View Full Code Here

        if (!getTransacted()) {
            throw new javax.jms.IllegalStateException("Not a transacted session");
        }
        // Only send commit if the transaction was started.
        if (this.startTransaction.commit(true, false)) {
            TransactionInfo info = new TransactionInfo();
            info.setId(this.packetIdGenerator.generateId());
            info.setTransactionId(currentTransactionId);
            info.setType(TransactionInfo.COMMIT);
            //before we send, update the current transaction id
            this.currentTransactionId = null;
            // Notify the listener that the tx was commited back
            this.connection.syncSendPacket(info);
            if (localTransactionEventListener != null) {
View Full Code Here

        if (!getTransacted()) {
            throw new javax.jms.IllegalStateException("Not a transacted session");
        }
        // Only rollback commit if the transaction was started.
        if (this.startTransaction.commit(true, false)) {
            TransactionInfo info = new TransactionInfo();
            info.setId(this.packetIdGenerator.generateId());
            info.setTransactionId(currentTransactionId);
            info.setType(TransactionInfo.ROLLBACK);
            //before we send, update the current transaction id
            this.currentTransactionId = null;
            this.connection.asyncSendPacket(info);
            // Notify the listener that the tx was rolled back
            if (localTransactionEventListener != null) {
View Full Code Here

     * @throws JMSException
     */
    protected void startLocalTransaction() throws JMSException {
        if (startTransaction.commit(false, true)) {
            this.currentTransactionId = transactionIdGenerator.generateId();
            TransactionInfo info = new TransactionInfo();
            info.setId(this.packetIdGenerator.generateId());
            info.setTransactionId(currentTransactionId);
            info.setType(TransactionInfo.START);
            this.connection.asyncSendPacket(info);
            // Notify the listener that the tx was started.
            if (localTransactionEventListener != null) {
                localTransactionEventListener.beginEvent();
            }
View Full Code Here

TOP

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

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.