Search in sources :

Example 96 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class DestinationMapMemoryTest method testVeryLongestinationPaths.

public void testVeryLongestinationPaths() throws Exception {
    for (int i = 1; i < 100; i++) {
        String name = "1";
        for (int j = 2; j <= i; j++) {
            name += "." + j;
        }
        // System.out.println("Checking: " + name);
        try {
            ActiveMQDestination d1 = createDestination(name);
            DestinationMap map = new DestinationMap();
            map.put(d1, d1);
        } catch (Throwable e) {
            fail("Destination name too long: " + name + " : " + e);
        }
    }
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 97 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class DestinationMapTest method remove.

protected void remove(String name, Object value) {
    ActiveMQDestination destination = createDestination(name);
    map.remove(destination, value);
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 98 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class ActiveMQDestinationTestSupport method populateObject.

@Override
protected void populateObject(Object object) throws Exception {
    super.populateObject(object);
    ActiveMQDestination info = (ActiveMQDestination) object;
    info.setPhysicalName("PhysicalName:1");
}
Also used : ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 99 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class MessageTransformationTest method testTransformDestination.

/**
 * Tests transforming destinations into ActiveMQ's destination
 * implementation.
 */
public void testTransformDestination() throws Exception {
    assertTrue("Transforming a TempQueue destination to an ActiveMQTempQueue", ActiveMQMessageTransformation.transformDestination(new ActiveMQTempQueue()) instanceof ActiveMQTempQueue);
    assertTrue("Transforming a TempTopic destination to an ActiveMQTempTopic", ActiveMQMessageTransformation.transformDestination(new ActiveMQTempTopic()) instanceof ActiveMQTempTopic);
    assertTrue("Transforming a Queue destination to an ActiveMQQueue", ActiveMQMessageTransformation.transformDestination(new ActiveMQQueue()) instanceof ActiveMQQueue);
    assertTrue("Transforming a Topic destination to an ActiveMQTopic", ActiveMQMessageTransformation.transformDestination(new ActiveMQTopic()) instanceof ActiveMQTopic);
    assertTrue("Transforming a Destination to an ActiveMQDestination", ActiveMQMessageTransformation.transformDestination(new ActiveMQTopic()) instanceof ActiveMQDestination);
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ActiveMQTempTopic(org.apache.activemq.command.ActiveMQTempTopic) ActiveMQQueue(org.apache.activemq.command.ActiveMQQueue) ActiveMQTempQueue(org.apache.activemq.command.ActiveMQTempQueue) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination)

Example 100 with ActiveMQDestination

use of org.apache.activemq.command.ActiveMQDestination in project activemq-artemis by apache.

the class XARecoveryBrokerTest method testTopicPersistentPreparedAcksNotLostOnRestart.

public void testTopicPersistentPreparedAcksNotLostOnRestart() throws Exception {
    ActiveMQDestination destination = new ActiveMQTopic("TryTopic");
    // Setup the producer and send the message.
    StubConnection connection = createConnection();
    ConnectionInfo connectionInfo = createConnectionInfo();
    connectionInfo.setClientId("durable");
    SessionInfo sessionInfo = createSessionInfo(connectionInfo);
    ProducerInfo producerInfo = createProducerInfo(sessionInfo);
    connection.send(connectionInfo);
    connection.send(sessionInfo);
    connection.send(producerInfo);
    // setup durable subs
    ConsumerInfo consumerInfo = createConsumerInfo(sessionInfo, destination);
    consumerInfo.setSubscriptionName("durable");
    connection.send(consumerInfo);
    final int numMessages = 4;
    for (int i = 0; i < numMessages; i++) {
        Message message = createMessage(producerInfo, destination);
        message.setPersistent(true);
        connection.send(message);
    }
    // Begin the transaction.
    XATransactionId txid = createXATransaction(sessionInfo);
    connection.send(createBeginTransaction(connectionInfo, txid));
    final int messageCount = expectedMessageCount(numMessages, destination);
    Message m = null;
    for (int i = 0; i < messageCount; i++) {
        m = receiveMessage(connection);
        assertNotNull("unexpected null on: " + i, m);
    }
    // one ack with last received, mimic a beforeEnd synchronization
    MessageAck ack = createAck(consumerInfo, m, messageCount, MessageAck.STANDARD_ACK_TYPE);
    ack.setTransactionId(txid);
    connection.send(ack);
    connection.request(createPrepareTransaction(connectionInfo, txid));
    // restart the broker.
    restartBroker();
    connection = createConnection();
    connectionInfo = createConnectionInfo();
    connectionInfo.setClientId("durable");
    connection.send(connectionInfo);
    // validate recovery
    TransactionInfo recoverInfo = new TransactionInfo(connectionInfo.getConnectionId(), null, TransactionInfo.RECOVER);
    DataArrayResponse dataArrayResponse = (DataArrayResponse) connection.request(recoverInfo);
    assertEquals("there is a prepared tx", 1, dataArrayResponse.getData().length);
    assertEquals("it matches", txid, dataArrayResponse.getData()[0]);
    sessionInfo = createSessionInfo(connectionInfo);
    connection.send(sessionInfo);
    consumerInfo = createConsumerInfo(sessionInfo, destination);
    consumerInfo.setSubscriptionName("durable");
    connection.send(consumerInfo);
    // no redelivery, exactly once semantics unless there is rollback
    m = receiveMessage(connection);
    assertNull(m);
    assertNoMessagesLeft(connection);
    connection.request(createCommitTransaction2Phase(connectionInfo, txid));
    // validate recovery complete
    dataArrayResponse = (DataArrayResponse) connection.request(recoverInfo);
    assertEquals("there are no prepared tx", 0, dataArrayResponse.getData().length);
}
Also used : ActiveMQTopic(org.apache.activemq.command.ActiveMQTopic) ProducerInfo(org.apache.activemq.command.ProducerInfo) ConsumerInfo(org.apache.activemq.command.ConsumerInfo) XATransactionId(org.apache.activemq.command.XATransactionId) Message(org.apache.activemq.command.Message) SessionInfo(org.apache.activemq.command.SessionInfo) MessageAck(org.apache.activemq.command.MessageAck) ActiveMQDestination(org.apache.activemq.command.ActiveMQDestination) TransactionInfo(org.apache.activemq.command.TransactionInfo) ConnectionInfo(org.apache.activemq.command.ConnectionInfo) DataArrayResponse(org.apache.activemq.command.DataArrayResponse)

Aggregations

ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)165 Session (javax.jms.Session)62 MessageConsumer (javax.jms.MessageConsumer)49 Message (org.apache.activemq.command.Message)46 ConsumerInfo (org.apache.activemq.command.ConsumerInfo)45 ConnectionInfo (org.apache.activemq.command.ConnectionInfo)44 SessionInfo (org.apache.activemq.command.SessionInfo)44 ProducerInfo (org.apache.activemq.command.ProducerInfo)42 Test (org.junit.Test)41 Message (javax.jms.Message)40 ActiveMQQueue (org.apache.activemq.command.ActiveMQQueue)40 TextMessage (javax.jms.TextMessage)31 BasicOpenWireTest (org.apache.activemq.artemis.tests.integration.openwire.BasicOpenWireTest)24 ActiveMQTopic (org.apache.activemq.command.ActiveMQTopic)22 MessageProducer (javax.jms.MessageProducer)18 XATransactionId (org.apache.activemq.command.XATransactionId)15 CountDownLatch (java.util.concurrent.CountDownLatch)14 ActiveMQMessageProducer (org.apache.activemq.ActiveMQMessageProducer)12 MessageAck (org.apache.activemq.command.MessageAck)12 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)11