Search in sources :

Example 6 with ClientMessage

use of org.apache.activemq.artemis.api.core.client.ClientMessage in project activemq-artemis by apache.

the class TransformTest method publish.

public static void publish(String destination, Serializable object, String contentType) throws Exception {
    ClientSession session = manager.getQueueManager().getSessionFactory().createSession();
    try {
        ClientProducer producer = session.createProducer(destination);
        ClientMessage message = session.createMessage(Message.OBJECT_TYPE, false);
        if (contentType == null) {
            ActiveMQ.setEntity(message, object);
        } else
            ActiveMQ.setEntity(message, object, contentType);
        producer.send(message);
        session.start();
    } finally {
        session.close();
    }
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer)

Example 7 with ClientMessage

use of org.apache.activemq.artemis.api.core.client.ClientMessage in project activemq-artemis by apache.

the class MultipleEmbeddedActiveMQResourcesTest method testMultipleServers.

@Test
public void testMultipleServers() throws Exception {
    ClientMessage sentOne = serverOne.sendMessage(TEST_ADDRESS_ONE, TEST_BODY);
    assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_ONE), sentOne);
    ClientMessage receivedOne = serverOne.receiveMessage(TEST_QUEUE_ONE);
    assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_TWO), receivedOne);
    ClientMessage sentTwo = serverTwo.sendMessage(TEST_ADDRESS_TWO, TEST_BODY);
    assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_TWO), sentOne);
    ClientMessage receivedTwo = serverTwo.receiveMessage(TEST_QUEUE_TWO);
    assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_TWO), receivedOne);
}
Also used : ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) Test(org.junit.Test)

Example 8 with ClientMessage

use of org.apache.activemq.artemis.api.core.client.ClientMessage in project activemq-artemis by apache.

the class ActiveMQDynamicProducerResourceTest method tearDown.

@After
public void tearDown() throws Exception {
    assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_ONE), sentOne);
    assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_QUEUE_TWO), sentTwo);
    Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisfied() throws Exception {
            return server.getMessageCount(TEST_QUEUE_ONE) == 1 && server.getMessageCount(TEST_QUEUE_TWO) == 1;
        }
    }, 5000, 100);
    assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE_ONE), 1, server.getMessageCount(TEST_QUEUE_ONE));
    assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE_TWO), 1, server.getMessageCount(TEST_QUEUE_TWO));
    ClientMessage receivedOne = server.receiveMessage(TEST_QUEUE_ONE);
    assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_ONE), receivedOne);
    ClientMessage receivedTwo = server.receiveMessage(TEST_QUEUE_TWO);
    assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE_TWO), receivedTwo);
    server.stop();
}
Also used : ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) After(org.junit.After)

Example 9 with ClientMessage

use of org.apache.activemq.artemis.api.core.client.ClientMessage in project activemq-artemis by apache.

the class EmbeddedActiveMQResourceTest method tearDown.

@After
public void tearDown() throws Exception {
    assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_ADDRESS), sent);
    Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisfied() throws Exception {
            return server.getMessageCount(TEST_QUEUE) == 1;
        }
    }, 5000, 100);
    assertEquals(String.format(ASSERT_COUNT_FORMAT, TEST_QUEUE), 1, server.getMessageCount(TEST_QUEUE));
    ClientMessage received = server.receiveMessage(TEST_QUEUE);
    assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_ADDRESS), received);
    server.stop();
}
Also used : ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) After(org.junit.After)

Example 10 with ClientMessage

use of org.apache.activemq.artemis.api.core.client.ClientMessage in project activemq-artemis by apache.

the class ActiveMQProducerResourceTest method checkResults.

@After
public void checkResults() throws Exception {
    assertNotNull(String.format(ASSERT_SENT_FORMAT, TEST_ADDRESS), sent);
    ClientMessage received = server.receiveMessage(TEST_QUEUE);
    assertNotNull(String.format(ASSERT_RECEIVED_FORMAT, TEST_QUEUE), received);
}
Also used : ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) After(org.junit.After)

Aggregations

ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)889 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)708 Test (org.junit.Test)647 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)623 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)606 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)445 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)363 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)167 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)140 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)102 CountDownLatch (java.util.concurrent.CountDownLatch)99 Configuration (org.apache.activemq.artemis.core.config.Configuration)87 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)85 Queue (org.apache.activemq.artemis.core.server.Queue)72 Xid (javax.transaction.xa.Xid)67 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)63 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)54 HashMap (java.util.HashMap)53 ArrayList (java.util.ArrayList)51 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)47