Search in sources :

Example 91 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class JournalPendingMessageTest method setupAddresses.

@Before
public void setupAddresses() throws Exception {
    server.getPostOffice().addAddressInfo(new AddressInfo(SimpleString.toSimpleString(defaultQueueName), RoutingType.ANYCAST));
    server.createQueue(SimpleString.toSimpleString(defaultQueueName), RoutingType.ANYCAST, SimpleString.toSimpleString(defaultQueueName), null, true, false);
}
Also used : AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Before(org.junit.Before)

Example 92 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class RestDeserializationTest method testWithoutBlackWhiteListTopic.

@Test
public void testWithoutBlackWhiteListTopic() throws Exception {
    jmsServer.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString("ordersTopic"), RoutingType.MULTICAST));
    deployAndconfigureRESTService("rest-test.war");
    RestMessageContext topicContext = restConnection.createTopicContext("ordersTopic");
    topicContext.initPullConsumers();
    Order order = new Order();
    order.setName("Bill");
    order.setItem("iPhone4");
    order.setAmount("$199.99");
    jmsSendMessage(order, "ordersTopic", false);
    String received = topicContext.pullMessage();
    Object object = xmlToObject(received);
    assertEquals(order, object);
}
Also used : RestMessageContext(org.apache.activemq.artemis.tests.integration.rest.util.RestMessageContext) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 93 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class StompTest method testPrefix.

public void testPrefix(final String prefix, final RoutingType routingType, final boolean send) throws Exception {
    int port = 61614;
    URI uri = createStompClientUri(scheme, hostname, port);
    final String ADDRESS = UUID.randomUUID().toString();
    final String PREFIXED_ADDRESS = prefix + ADDRESS;
    String param = routingType.toString();
    String urlParam = param.toLowerCase() + "Prefix";
    server.getActiveMQServer().getRemotingService().createAcceptor("test", "tcp://" + hostname + ":" + port + "?protocols=" + StompProtocolManagerFactory.STOMP_PROTOCOL_NAME + "&" + urlParam + "=" + prefix).start();
    StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
    conn.connect(defUser, defPass);
    // since this queue doesn't exist the broker should create a new address using the routing type matching the prefix
    if (send) {
        send(conn, PREFIXED_ADDRESS, null, "Hello World", true);
    } else {
        String uuid = UUID.randomUUID().toString();
        ClientStompFrame frame = conn.createFrame(Stomp.Commands.SUBSCRIBE).addHeader(Stomp.Headers.Subscribe.DESTINATION, PREFIXED_ADDRESS).addHeader(Stomp.Headers.RECEIPT_REQUESTED, uuid);
        frame = conn.sendFrame(frame);
        assertEquals(uuid, frame.getHeader(Stomp.Headers.Response.RECEIPT_ID));
    }
    AddressInfo addressInfo = server.getActiveMQServer().getAddressInfo(SimpleString.toSimpleString(ADDRESS));
    assertNotNull("No address was created with the name " + ADDRESS, addressInfo);
    Set<RoutingType> routingTypes = new HashSet<>();
    routingTypes.add(RoutingType.valueOf(param));
    assertEquals(routingTypes, addressInfo.getRoutingTypes());
    conn.disconnect();
}
Also used : ClientStompFrame(org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame) StompClientConnection(org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) URI(java.net.URI) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) RoutingType(org.apache.activemq.artemis.api.core.RoutingType) HashSet(java.util.HashSet)

Example 94 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class FindDestinationTest method testFindQueue.

@Test
public void testFindQueue() throws Exception {
    String testName = "testFindQueue";
    server.getActiveMQServer().addAddressInfo(new AddressInfo(SimpleString.toSimpleString(testName), RoutingType.MULTICAST));
    server.getActiveMQServer().createQueue(new SimpleString(testName), RoutingType.MULTICAST, new SimpleString(testName), null, false, false);
    ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/queues/" + testName));
    ClientResponse<?> response = request.head();
    response.releaseConnection();
    Assert.assertEquals(200, response.getStatus());
    Link sender = getLinkByTitle(manager.getTopicManager().getLinkStrategy(), response, "create");
    System.out.println("create: " + sender);
    Link consumers = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "pull-consumers");
    System.out.println("pull: " + consumers);
    response = Util.setAutoAck(consumers, true);
    Link consumeNext = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), response, "consume-next");
    System.out.println("poller: " + consumeNext);
    ClientResponse<?> res = sender.request().body("text/plain", Integer.toString(1)).post();
    res.releaseConnection();
    Assert.assertEquals(201, res.getStatus());
    res = consumeNext.request().post(String.class);
    Assert.assertEquals(200, res.getStatus());
    Assert.assertEquals("1", res.getEntity(String.class));
    res.releaseConnection();
    Link session = getLinkByTitle(manager.getQueueManager().getLinkStrategy(), res, "consumer");
    System.out.println("session: " + session);
    Assert.assertEquals(204, session.request().delete().getStatus());
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ClientRequest(org.jboss.resteasy.client.ClientRequest) Link(org.jboss.resteasy.spi.Link) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 95 with AddressInfo

use of org.apache.activemq.artemis.core.server.impl.AddressInfo in project activemq-artemis by apache.

the class RawAckTest method setup.

@BeforeClass
public static void setup() throws Exception {
    Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    activeMQServer = ActiveMQServers.newActiveMQServer(configuration);
    activeMQServer.start();
    HashMap<String, Object> transportConfig = new HashMap<>();
    serverLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig));
    sessionFactory = serverLocator.createSessionFactory();
    consumerSessionFactory = serverLocator.createSessionFactory();
    SimpleString addr = SimpleString.toSimpleString("testQueue");
    activeMQServer.addAddressInfo(new AddressInfo(addr, RoutingType.MULTICAST));
    activeMQServer.createQueue(addr, RoutingType.MULTICAST, addr, null, false, false);
    session = sessionFactory.createSession(true, true);
    producer = session.createProducer(addr);
    session.start();
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) HashMap(java.util.HashMap) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) BeforeClass(org.junit.BeforeClass)

Aggregations

AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)116 Test (org.junit.Test)89 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)73 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)32 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)24 AmqpConnection (org.apache.activemq.transport.amqp.client.AmqpConnection)23 AmqpSession (org.apache.activemq.transport.amqp.client.AmqpSession)23 AmqpClient (org.apache.activemq.transport.amqp.client.AmqpClient)22 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)21 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)19 AmqpMessage (org.apache.activemq.transport.amqp.client.AmqpMessage)18 AmqpReceiver (org.apache.activemq.transport.amqp.client.AmqpReceiver)17 JsonObject (javax.json.JsonObject)16 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)16 ActiveMQServerControl (org.apache.activemq.artemis.api.core.management.ActiveMQServerControl)16 JsonArray (javax.json.JsonArray)15 Queue (org.apache.activemq.artemis.core.server.Queue)15 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)13 Configuration (org.apache.activemq.artemis.core.config.Configuration)12 Session (javax.jms.Session)11