Java Code Examples for org.apache.activemq.artemis.core.settings.impl.AddressSettings#setDefaultConsumerWindowSize()

The following examples show how to use org.apache.activemq.artemis.core.settings.impl.AddressSettings#setDefaultConsumerWindowSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConsumerWindowSizeTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerWindowSizeAddressSettings() throws Exception {
   ActiveMQServer messagingService = createServer(false, isNetty());

   final int defaultConsumerWindowSize = 1024 * 5;
   final AddressSettings settings = new AddressSettings();
   settings.setDefaultConsumerWindowSize(defaultConsumerWindowSize);
   messagingService.getConfiguration()
         .getAddressesSettings().put(queueA.toString(), settings);

   messagingService.start();
   messagingService.createQueue(new QueueConfiguration(queueA).setRoutingType(RoutingType.ANYCAST));

   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession(false, true, true);
   ClientConsumerImpl consumer = (ClientConsumerImpl) session.createConsumer(queueA);

   session.start();

   assertEquals(defaultConsumerWindowSize / 2, consumer.getClientWindowSize());
}
 
Example 2
Source File: ConsumerWindowSizeTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerWindowSizeAddressSettingsDifferentAddressAndQueueName() throws Exception {
   ActiveMQServer messagingService = createServer(false, isNetty());

   final int defaultConsumerWindowSize = 1024 * 5;
   final AddressSettings settings = new AddressSettings();
   settings.setDefaultConsumerWindowSize(defaultConsumerWindowSize);
   messagingService.getConfiguration()
         .getAddressesSettings().put(addressA.toString(), settings);

   messagingService.start();
   messagingService.createQueue(new QueueConfiguration(queueA).setAddress(addressA).setRoutingType(RoutingType.ANYCAST));

   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession(false, true, true);
   ClientConsumerImpl consumer = (ClientConsumerImpl) session.createConsumer(queueA);

   session.start();

   assertEquals(defaultConsumerWindowSize / 2, consumer.getClientWindowSize());

   ServerSession ss = messagingService.getSessionByID(((ClientSessionImpl)session).getName());
   ServerConsumerImpl cons = (ServerConsumerImpl) ss.locateConsumer(consumer.getConsumerContext().getId());

   assertTrue(Wait.waitFor(() -> cons.getAvailableCredits().get() == consumer.getClientWindowSize() * 2, 5000, 50));
}
 
Example 3
Source File: ConsumerWindowSizeTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumerWindowSizeAddressSettingsWildCard() throws Exception {
   ActiveMQServer messagingService = createServer(false, isNetty());

   final int defaultConsumerWindowSize = 1024 * 5;
   final AddressSettings settings = new AddressSettings();
   settings.setDefaultConsumerWindowSize(defaultConsumerWindowSize);
   messagingService.getConfiguration()
      .getAddressesSettings().put("#", settings);

   messagingService.start();
   messagingService.createQueue(new QueueConfiguration(queueA).setRoutingType(RoutingType.ANYCAST));

   ClientSessionFactory cf = createSessionFactory(locator);
   ClientSession session = cf.createSession(false, true, true);
   ClientConsumerImpl consumer = (ClientConsumerImpl) session.createConsumer(queueA);
   ClientConsumerImpl consumer2 = (ClientConsumerImpl) session.createConsumer(queueA);

   session.start();

   assertEquals(defaultConsumerWindowSize / 2, consumer.getClientWindowSize());
   assertEquals(defaultConsumerWindowSize / 2, consumer2.getClientWindowSize());
}