Search in sources :

Example 31 with LocalQueueBinding

use of org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding in project activemq-artemis by apache.

the class TopicCleanupTest method testSendTopic.

@Test
public void testSendTopic() throws Exception {
    Topic topic = createTopic("topic");
    Connection conn = cf.createConnection();
    try {
        conn.setClientID("someID");
        Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageConsumer cons = sess.createDurableSubscriber(topic, "someSub");
        conn.start();
        MessageProducer prod = sess.createProducer(topic);
        TextMessage msg1 = sess.createTextMessage("text");
        prod.send(msg1);
        assertNotNull(cons.receive(5000));
        conn.close();
        StorageManager storage = server.getStorageManager();
        for (int i = 0; i < 100; i++) {
            long txid = storage.generateID();
            final Queue queue = new QueueImpl(storage.generateID(), SimpleString.toSimpleString("topic"), SimpleString.toSimpleString("topic"), FilterImpl.createFilter(Filter.GENERIC_IGNORED_FILTER), null, true, false, false, server.getScheduledPool(), server.getPostOffice(), storage, server.getAddressSettingsRepository(), server.getExecutorFactory().getExecutor(), server, null);
            LocalQueueBinding binding = new LocalQueueBinding(queue.getAddress(), queue, server.getNodeID());
            storage.addQueueBinding(txid, binding);
            storage.commitBindings(txid);
        }
        jmsServer.stop();
        jmsServer.start();
    } finally {
        try {
            conn.close();
        } catch (Throwable igonred) {
        }
    }
}
Also used : MessageConsumer(javax.jms.MessageConsumer) Connection(javax.jms.Connection) StorageManager(org.apache.activemq.artemis.core.persistence.StorageManager) QueueImpl(org.apache.activemq.artemis.core.server.impl.QueueImpl) LocalQueueBinding(org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding) MessageProducer(javax.jms.MessageProducer) Topic(javax.jms.Topic) ActiveMQTopic(org.apache.activemq.artemis.jms.client.ActiveMQTopic) Queue(org.apache.activemq.artemis.core.server.Queue) TextMessage(javax.jms.TextMessage) Session(javax.jms.Session) Test(org.junit.Test)

Aggregations

LocalQueueBinding (org.apache.activemq.artemis.core.postoffice.impl.LocalQueueBinding)31 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)22 Binding (org.apache.activemq.artemis.core.postoffice.Binding)19 Test (org.junit.Test)18 Queue (org.apache.activemq.artemis.core.server.Queue)14 Bindings (org.apache.activemq.artemis.core.postoffice.Bindings)10 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)9 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)8 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)8 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)7 QueueBinding (org.apache.activemq.artemis.core.postoffice.QueueBinding)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 PostOffice (org.apache.activemq.artemis.core.postoffice.PostOffice)5 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)5 ArrayList (java.util.ArrayList)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 PostOfficeImpl (org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl)4 QueueQueryResult (org.apache.activemq.artemis.core.server.QueueQueryResult)4 PrintWriter (java.io.PrintWriter)3 StringWriter (java.io.StringWriter)3