Package org.activemq.message

Examples of org.activemq.message.XATransactionInfo


    }


    public Xid[] recover(int flag) throws XAException {

        XATransactionInfo info = new XATransactionInfo();
        info.setType(XATransactionInfo.XA_RECOVER);

        try {
            ResponseReceipt receipt = (ResponseReceipt) this.connection.syncSendRequest(info);
            return (ActiveMQXid[]) receipt.getResult();
        } catch (JMSException e) {
View Full Code Here


        }
    }

    public int getTransactionTimeout() throws XAException {

        XATransactionInfo info = new XATransactionInfo();
        info.setType(XATransactionInfo.GET_TX_TIMEOUT);

        try {
            // get the tx timeout that was set.
            IntResponseReceipt receipt = (IntResponseReceipt) this.connection.syncSendRequest(info);
            return receipt.getResult();
View Full Code Here

        }
    }

    public boolean setTransactionTimeout(int seconds) throws XAException {

        XATransactionInfo info = new XATransactionInfo();
        info.setType(XATransactionInfo.SET_TX_TIMEOUT);
        info.setTransactionTimeout(seconds);

        try {
            // Setup the new tx timeout
            this.connection.asyncSendPacket(info);
            return true;
View Full Code Here

    /**
     * @return a new Packet instance
     */

    public Packet createPacket() {
        return new XATransactionInfo();
    }
View Full Code Here

     * @throws java.io.IOException
     */

    public void buildPacket(Packet packet, DataInput dataIn) throws IOException {
        super.buildPacket(packet, dataIn);
        XATransactionInfo info = (XATransactionInfo) packet;
        info.setType(dataIn.readByte());
        switch (info.getType()) {
            case TransactionType.START:
            case TransactionType.PRE_COMMIT:
            case TransactionType.COMMIT:
            case TransactionType.RECOVER:
            case TransactionType.ROLLBACK:
            case TransactionType.END:
            case TransactionType.FORGET:
            case TransactionType.JOIN:
            case TransactionType.COMMIT_ONE_PHASE:
                info.setXid(ActiveMQXid.read(dataIn));
                break;
            case TransactionType.SET_TX_TIMEOUT:
                info.setTransactionTimeout(dataIn.readInt());
                break;
            case TransactionType.XA_RECOVER:
                //recover should take a flag.
                break;
            case TransactionType.GET_TX_TIMEOUT:
            case TransactionType.GET_RM_ID:
                break;
            default:
                throw new IllegalArgumentException("Invalid type code: " + info.getType());
        }
    }
View Full Code Here

        XATransactionInfoReader reader = new XATransactionInfoReader();
        assertTrue(reader.getPacketType() == Packet.XA_TRANSACTION_INFO);
    }

    public void testReadXidPacket() throws Exception {
        XATransactionInfo info = (XATransactionInfo) createXidPacket();

        XATransactionInfoWriter writer = new XATransactionInfoWriter();
        XATransactionInfoReader reader = new XATransactionInfoReader();
        byte[] data = writer.writePacketToByteArray(info);
        XATransactionInfo testInfo = (XATransactionInfo) reader.readPacketFromByteArray(data);

        assertPacket(testInfo, info);
    }
View Full Code Here

        assertPacket(testInfo, info);
    }

    public void testReadNoXidPacket() throws Exception {
        XATransactionInfo info = (XATransactionInfo) createNoXidPacket();

        XATransactionInfoWriter writer = new XATransactionInfoWriter();
        XATransactionInfoReader reader = new XATransactionInfoReader();
        byte[] data = writer.writePacketToByteArray(info);
        XATransactionInfo testInfo = (XATransactionInfo) reader.readPacketFromByteArray(data);

        assertPacket(testInfo, info);
    }
View Full Code Here

        assertPacket(testInfo, info);
    }

    public void testTime() {
        XATransactionInfo info = (XATransactionInfo) createXidPacket();

        XATransactionInfoWriter writer = new XATransactionInfoWriter();
        XATransactionInfoReader reader = new XATransactionInfoReader();
        XATransactionInfo 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

            fail();
        }
    }

    protected void assertPacket(Packet packet, Packet expected) {
        XATransactionInfo testInfo = (XATransactionInfo) packet;
        XATransactionInfo xaExpected = (XATransactionInfo) expected;
        assertEquals(xaExpected.getType(), testInfo.getType());
        assertEquals(xaExpected.getXid(), testInfo.getXid());
    }
View Full Code Here

        assertEquals(xaExpected.getType(), testInfo.getType());
        assertEquals(xaExpected.getXid(), testInfo.getXid());
    }

    protected void assertValidPacket(Packet packet) {
        XATransactionInfo testInfo = (XATransactionInfo) packet;
        assertEquals(testInfo.getType(), TYPE);
        assertEquals(testInfo.getXid(), XID);
    }
View Full Code Here

TOP

Related Classes of org.activemq.message.XATransactionInfo

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.