Example usage for javax.jms Queue getQueueName

List of usage examples for javax.jms Queue getQueueName

Introduction

In this page you can find the example usage for javax.jms Queue getQueueName.

Prototype


String getQueueName() throws JMSException;

Source Link

Document

Gets the name of this queue.

Usage

From source file:org.apache.activemq.bugs.AMQ7067Test.java

@Test
public void testXAPrepare() throws Exception {

    setupXAConnection();/*from   w  w  w  .ja  v  a  2s.  com*/

    Queue holdKahaDb = xaSession.createQueue("holdKahaDb");

    MessageProducer holdKahaDbProducer = xaSession.createProducer(holdKahaDb);

    XATransactionId txid = createXATransaction();
    System.out.println("****** create new txid = " + txid);
    xaRes.start(txid, TMNOFLAGS);

    TextMessage helloMessage = xaSession.createTextMessage(StringUtils.repeat("a", 10));
    holdKahaDbProducer.send(helloMessage);
    xaRes.end(txid, TMSUCCESS);

    Queue queue = xaSession.createQueue("test");

    produce(xaRes, xaSession, queue, 100, 512 * 1024);

    xaRes.prepare(txid);

    produce(xaRes, xaSession, queue, 100, 512 * 1024);

    ((org.apache.activemq.broker.region.Queue) broker.getRegionBroker().getDestinationMap().get(queue)).purge();

    Wait.waitFor(new Wait.Condition() {
        @Override
        public boolean isSatisified() throws Exception {
            return 0 == getQueueSize(queue.getQueueName());
        }
    });

    // force gc
    broker.getPersistenceAdapter().checkpoint(true);

    Xid[] xids = xaRes.recover(TMSTARTRSCAN);

    //Should be 1 since we have only 1 prepared
    assertEquals(1, xids.length);
    connection.close();

    broker.stop();
    broker.waitUntilStopped();
    createBroker();

    setupXAConnection();
    xids = xaRes.recover(TMSTARTRSCAN);

    System.out.println("****** recovered = " + xids);

    // THIS SHOULD NOT FAIL AS THERE SHOULD DBE ONLY 1 TRANSACTION!
    assertEquals(1, xids.length);
}

From source file:org.apache.activemq.bugs.AMQ7067Test.java

@Test
public void testXAPrepareWithAckCompactionDoesNotLooseInflight() throws Exception {

    // investigate liner gc issue - store usage not getting released
    org.apache.log4j.Logger.getLogger(MessageDatabase.class).setLevel(Level.TRACE);

    setupXAConnection();//  w w  w .  j a v a 2s.  c o  m

    Queue holdKahaDb = xaSession.createQueue("holdKahaDb");

    MessageProducer holdKahaDbProducer = xaSession.createProducer(holdKahaDb);

    XATransactionId txid = createXATransaction();
    System.out.println("****** create new txid = " + txid);
    xaRes.start(txid, TMNOFLAGS);

    TextMessage helloMessage = xaSession.createTextMessage(StringUtils.repeat("a", 10));
    holdKahaDbProducer.send(helloMessage);
    xaRes.end(txid, TMSUCCESS);

    Queue queue = xaSession.createQueue("test");

    produce(xaRes, xaSession, queue, 100, 512 * 1024);

    xaRes.prepare(txid);

    produce(xaRes, xaSession, queue, 100, 512 * 1024);

    ((org.apache.activemq.broker.region.Queue) broker.getRegionBroker().getDestinationMap().get(queue)).purge();

    Wait.waitFor(new Wait.Condition() {
        @Override
        public boolean isSatisified() throws Exception {
            return 0 == getQueueSize(queue.getQueueName());
        }
    });

    // force gc, two data files requires two cycles
    int limit = ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).getCompactAcksAfterNoGC() + 1;
    for (int i = 0; i < limit * 2; i++) {
        broker.getPersistenceAdapter().checkpoint(true);
    }

    // ack compaction task operates in the background
    TimeUnit.SECONDS.sleep(5);

    Xid[] xids = xaRes.recover(TMSTARTRSCAN);

    //Should be 1 since we have only 1 prepared
    assertEquals(1, xids.length);
    connection.close();

    broker.stop();
    broker.waitUntilStopped();
    createBroker();

    setupXAConnection();
    xids = xaRes.recover(TMSTARTRSCAN);

    System.out.println("****** recovered = " + xids);

    // THIS SHOULD NOT FAIL AS THERE SHOULD DBE ONLY 1 TRANSACTION!
    assertEquals(1, xids.length);
}

From source file:org.apache.activemq.bugs.AMQ7067Test.java

protected void doTestXACompletionWithAckCompactionDoesNotLooseOutcomeOnFullRecovery(boolean commit)
        throws Exception {

    ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).setCompactAcksAfterNoGC(2);
    // investigate liner gc issue - store usage not getting released
    org.apache.log4j.Logger.getLogger(MessageDatabase.class).setLevel(Level.TRACE);

    setupXAConnection();//from  w ww .  j  a  v  a  2s . c om

    Queue holdKahaDb = xaSession.createQueue("holdKahaDb");

    MessageProducer holdKahaDbProducer = xaSession.createProducer(holdKahaDb);

    XATransactionId txid = createXATransaction();
    System.out.println("****** create new txid = " + txid);
    xaRes.start(txid, TMNOFLAGS);

    TextMessage helloMessage = xaSession.createTextMessage(StringUtils.repeat("a", 10));
    holdKahaDbProducer.send(helloMessage);
    xaRes.end(txid, TMSUCCESS);

    Queue queue = xaSession.createQueue("test");

    produce(xaRes, xaSession, queue, 100, 512 * 1024);
    ((org.apache.activemq.broker.region.Queue) broker.getRegionBroker().getDestinationMap().get(queue)).purge();

    xaRes.prepare(txid);

    // hold onto data file with prepare record
    produce(xaRes, xaSession, holdKahaDb, 1, 10);

    produce(xaRes, xaSession, queue, 50, 512 * 1024);
    ((org.apache.activemq.broker.region.Queue) broker.getRegionBroker().getDestinationMap().get(queue)).purge();

    Wait.waitFor(new Wait.Condition() {
        @Override
        public boolean isSatisified() throws Exception {
            return 0 == getQueueSize(queue.getQueueName());
        }
    });

    if (commit) {
        xaRes.commit(txid, false);
    } else {
        xaRes.rollback(txid);
    }

    produce(xaRes, xaSession, queue, 50, 512 * 1024);
    ((org.apache.activemq.broker.region.Queue) broker.getRegionBroker().getDestinationMap().get(queue)).purge();

    Wait.waitFor(new Wait.Condition() {
        @Override
        public boolean isSatisified() throws Exception {
            return 0 == getQueueSize(queue.getQueueName());
        }
    });

    int limit = ((KahaDBPersistenceAdapter) broker.getPersistenceAdapter()).getCompactAcksAfterNoGC() + 1;
    // force gc, n data files requires n cycles
    for (int dataFilesToMove = 0; dataFilesToMove < 4; dataFilesToMove++) {
        for (int i = 0; i < limit; i++) {
            broker.getPersistenceAdapter().checkpoint(true);
        }
        // ack compaction task operates in the background
        TimeUnit.SECONDS.sleep(2);
    }

    Xid[] xids = xaRes.recover(TMSTARTRSCAN);

    //Should be 0 since we have delivered the outcome
    assertEquals(0, xids.length);
    connection.close();

    // need full recovery to see lost commit record
    curruptIndexFile(getDataDirectory());

    broker.stop();
    broker.waitUntilStopped();
    createBroker();

    setupXAConnection();
    xids = xaRes.recover(TMSTARTRSCAN);

    System.out.println("****** recovered = " + xids);

    assertEquals(0, xids.length);
}

From source file:org.apache.activemq.bugs.AMQ7067Test.java

@Test
public void testXAcommit() throws Exception {

    setupXAConnection();/*from  w  w w .j av a2s  .c o m*/

    Queue holdKahaDb = xaSession.createQueue("holdKahaDb");
    createDanglingTransaction(xaRes, xaSession, holdKahaDb);

    MessageProducer holdKahaDbProducer = xaSession.createProducer(holdKahaDb);

    XATransactionId txid = createXATransaction();
    System.out.println("****** create new txid = " + txid);
    xaRes.start(txid, TMNOFLAGS);

    TextMessage helloMessage = xaSession.createTextMessage(StringUtils.repeat("a", 10));
    holdKahaDbProducer.send(helloMessage);
    xaRes.end(txid, TMSUCCESS);
    xaRes.prepare(txid);

    Queue queue = xaSession.createQueue("test");

    produce(xaRes, xaSession, queue, 100, 512 * 1024);
    xaRes.commit(txid, false);
    produce(xaRes, xaSession, queue, 100, 512 * 1024);

    ((org.apache.activemq.broker.region.Queue) broker.getRegionBroker().getDestinationMap().get(queue)).purge();

    Wait.waitFor(new Wait.Condition() {
        @Override
        public boolean isSatisified() throws Exception {
            return 0 == getQueueSize(queue.getQueueName());
        }
    });

    // force gc
    broker.getPersistenceAdapter().checkpoint(true);

    Xid[] xids = xaRes.recover(TMSTARTRSCAN);

    //Should be 1 since we have only 1 prepared
    assertEquals(1, xids.length);
    connection.close();

    broker.stop();
    broker.waitUntilStopped();
    createBroker();

    setupXAConnection();
    xids = xaRes.recover(TMSTARTRSCAN);

    // THIS SHOULD NOT FAIL AS THERE SHOULD DBE ONLY 1 TRANSACTION!
    assertEquals(1, xids.length);

}

From source file:org.apache.activemq.bugs.AMQ7067Test.java

@Test
public void testCommit() throws Exception {
    final Connection connection = ACTIVE_MQ_NON_XA_CONNECTION_FACTORY.createConnection();
    connection.start();/*from  ww  w. j a v  a2 s. c  o m*/

    Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
    Queue holdKahaDb = session.createQueue("holdKahaDb");
    MessageProducer holdKahaDbProducer = session.createProducer(holdKahaDb);
    TextMessage helloMessage = session.createTextMessage(StringUtils.repeat("a", 10));
    holdKahaDbProducer.send(helloMessage);
    Queue queue = session.createQueue("test");
    produce(connection, queue, 100, 512 * 1024);
    session.commit();
    produce(connection, queue, 100, 512 * 1024);

    System.out.println(String.format("QueueSize %s: %d", holdKahaDb.getQueueName(),
            getQueueSize(holdKahaDb.getQueueName())));
    purgeQueue(queue.getQueueName());
    Wait.waitFor(new Wait.Condition() {
        @Override
        public boolean isSatisified() throws Exception {
            return 0 == getQueueSize(queue.getQueueName());
        }
    });

    // force gc
    broker.getPersistenceAdapter().checkpoint(true);

    connection.close();
    curruptIndexFile(getDataDirectory());

    broker.stop();
    broker.waitUntilStopped();
    createBroker();
    broker.waitUntilStarted();

    while (true) {
        try {
            TimeUnit.SECONDS.sleep(1);
            System.out.println(String.format("QueueSize %s: %d", holdKahaDb.getQueueName(),
                    getQueueSize(holdKahaDb.getQueueName())));
            break;
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            break;
        }
    }

    // THIS SHOULD NOT FAIL AS THERE SHOULD BE ONLY 1 TRANSACTION!
    assertEquals(1, getQueueSize(holdKahaDb.getQueueName()));
}

From source file:org.apache.activemq.bugs.AMQ7067Test.java

@Test
public void testRollback() throws Exception {
    final Connection connection = ACTIVE_MQ_NON_XA_CONNECTION_FACTORY.createConnection();
    connection.start();//from   w w  w. j a  v a2s  .  c  o m

    Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
    Queue holdKahaDb = session.createQueue("holdKahaDb");
    MessageProducer holdKahaDbProducer = session.createProducer(holdKahaDb);
    TextMessage helloMessage = session.createTextMessage(StringUtils.repeat("a", 10));
    holdKahaDbProducer.send(helloMessage);
    Queue queue = session.createQueue("test");
    produce(connection, queue, 100, 512 * 1024);
    session.rollback();
    produce(connection, queue, 100, 512 * 1024);

    System.out.println(String.format("QueueSize %s: %d", holdKahaDb.getQueueName(),
            getQueueSize(holdKahaDb.getQueueName())));
    purgeQueue(queue.getQueueName());

    Wait.waitFor(new Wait.Condition() {
        @Override
        public boolean isSatisified() throws Exception {
            return 0 == getQueueSize(queue.getQueueName());
        }
    });

    // force gc
    broker.getPersistenceAdapter().checkpoint(true);

    connection.close();
    curruptIndexFile(getDataDirectory());

    broker.stop();
    broker.waitUntilStopped();
    createBroker();
    broker.waitUntilStarted();

    // no sign of the test queue on recovery, rollback is the default for any inflight
    // this test serves as a sanity check on existing behaviour
    try {
        getQueueSize(holdKahaDb.getQueueName());
        fail("expect InstanceNotFoundException");
    } catch (UndeclaredThrowableException expected) {
        assertTrue(expected.getCause() instanceof InstanceNotFoundException);
    }
}

From source file:org.apache.camel.component.jms.JmsQueueEndpoint.java

public JmsQueueEndpoint(Queue destination) throws JMSException {
    this("jms:queue:" + destination.getQueueName(), null);
    setDestination(destination);//from  w ww  .  j a v  a 2 s . c  o m
}

From source file:org.apache.qpid.systest.management.jmx.QueueManagementTest.java

public void testQueueAttributes() throws Exception {
    Queue queue = _session.createQueue(getTestQueueName());
    createQueueOnBroker(queue);//from w w  w .j av  a2 s  .c om

    final String queueName = queue.getQueueName();

    final ManagedQueue managedQueue = _jmxUtils.getManagedQueue(queueName);
    assertEquals("Unexpected name", queueName, managedQueue.getName());
    assertEquals("Unexpected queue type", "standard", managedQueue.getQueueType());
}

From source file:org.apache.qpid.systest.management.jmx.QueueManagementTest.java

public void testExclusiveQueueHasJmsClientIdAsOwner() throws Exception {
    Queue tmpQueue = _session.createTemporaryQueue();

    final String queueName = tmpQueue.getQueueName();

    final ManagedQueue managedQueue = _jmxUtils.getManagedQueue(queueName);
    assertNotNull(_connection.getClientID());
    assertEquals("Unexpected owner", _connection.getClientID(), managedQueue.getOwner());
}

From source file:org.apache.qpid.systest.management.jmx.QueueManagementTest.java

public void testNonExclusiveQueueHasNoOwner() throws Exception {
    Queue nonExclusiveQueue = _session.createQueue(getTestQueueName());
    createQueueOnBroker(nonExclusiveQueue);

    final String queueName = nonExclusiveQueue.getQueueName();

    final ManagedQueue managedQueue = _jmxUtils.getManagedQueue(queueName);
    assertNull("Unexpected owner", managedQueue.getOwner());
}