org.apache.activemq.artemis.core.config.Configuration Java Examples

The following examples show how to use org.apache.activemq.artemis.core.config.Configuration. 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: AMQPToStompTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
   super.setUp();
   server = createServer(true, true);
   server.start();
   server.waitForActivation(10, TimeUnit.SECONDS);

   Configuration serverConfig = server.getConfiguration();
   serverConfig.getAddressesSettings().put("#", new AddressSettings().setAutoCreateQueues(false)
                                                                     .setAutoCreateAddresses(false)
                                                                     .setDeadLetterAddress(new SimpleString("ActiveMQ.DLQ")));
   serverConfig.setSecurityEnabled(false);
   coreQueue = new SimpleString(queueName);
   server.createQueue(new QueueConfiguration(coreQueue).setRoutingType(RoutingType.ANYCAST).setDurable(false));
}
 
Example #2
Source File: ClusterTestBase.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void setupClusterConnection(final String name,
                                      final String address,
                                      final MessageLoadBalancingType messageLoadBalancingType,
                                      final int maxHops,
                                      final boolean netty,
                                      final ClusterConfigCallback cb,
                                      final int nodeFrom,
                                      final int... nodesTo) {
   ActiveMQServer serverFrom = servers[nodeFrom];

   if (serverFrom == null) {
      throw new IllegalStateException("No server at node " + nodeFrom);
   }

   TransportConfiguration connectorFrom = createTransportConfiguration(netty, false, generateParams(nodeFrom, netty));
   serverFrom.getConfiguration().getConnectorConfigurations().put(connectorFrom.getName(), connectorFrom);

   List<String> pairs = getClusterConnectionTCNames(netty, serverFrom, nodesTo);
   Configuration config = serverFrom.getConfiguration();
   ClusterConnectionConfiguration clusterConf = createClusterConfig(name, address, messageLoadBalancingType, maxHops, connectorFrom, pairs);

   if (cb != null) {
      cb.configure(clusterConf);
   }
   config.getClusterConfigurations().add(clusterConf);
}
 
Example #3
Source File: ManagementServiceImplTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testHandleManagementMessageWithUnknowResource() throws Exception {
   Configuration config = createBasicConfig().setJMXManagementEnabled(false);

   ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
   server.start();

   // invoke attribute and operation on the server
   ICoreMessage message = new CoreMessage(1, 100);
   ManagementHelper.putOperationInvocation(message, "Resouce.Does.Not.Exist", "toString");

   ICoreMessage reply = server.getManagementService().handleMessage(message);

   Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
   Assert.assertNotNull(ManagementHelper.getResult(reply));
}
 
Example #4
Source File: ConsumerCloseTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
   super.setUp();

   Configuration config = createDefaultInVMConfig();

   server = addServer(ActiveMQServers.newActiveMQServer(config, false));
   server.start();

   address = RandomUtil.randomSimpleString();
   queue = RandomUtil.randomSimpleString();

   locator = createInVMNonHALocator();

   sf = createSessionFactory(locator);

   session = addClientSession(sf.createSession(false, true, true));
   session.createQueue(new QueueConfiguration(queue).setAddress(address).setDurable(false));
}
 
Example #5
Source File: EmbeddedTestServer.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void start() throws Exception {
   log.debug("\nStarting EmbeddedTestServer");
   if (activeMQServer == null) {
      Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));

      activeMQServer = ActiveMQServers.newActiveMQServer(configuration);
      // set DLA and expiry to avoid spamming the log with warnings
      activeMQServer.getAddressSettingsRepository().addMatch("#", new AddressSettings().setDeadLetterAddress(SimpleString.toSimpleString("DLA")).setExpiryAddress(SimpleString.toSimpleString("Expiry")));

      activeMQServer.start();
   }
   tjws.start();
   manager.setConfiguration(config);
   manager.start();
   tjws.getDeployment().getRegistry().addSingletonResource(manager.getQueueManager().getDestination());
   tjws.getDeployment().getRegistry().addSingletonResource(manager.getTopicManager().getDestination());

}
 
Example #6
Source File: RawAckTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@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(new QueueConfiguration(addr).setDurable(false));
   session = sessionFactory.createSession(true, true);
   producer = session.createProducer(addr);
   session.start();
}
 
Example #7
Source File: ManagementWithPagingServerTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
   super.setUp();

   Configuration config = createDefaultInVMConfig().setJMXManagementEnabled(true);

   server = addServer(ActiveMQServers.newActiveMQServer(config, mbeanServer, true));

   AddressSettings defaultSetting = new AddressSettings().setPageSizeBytes(5120).setMaxSizeBytes(10240).setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);

   server.getAddressSettingsRepository().addMatch("#", defaultSetting);

   server.start();

   locator = createInVMNonHALocator().setBlockOnNonDurableSend(false).setConsumerWindowSize(0);
   ClientSessionFactory sf = createSessionFactory(locator);
   session1 = sf.createSession(false, true, false);
   session1.start();
   session2 = sf.createSession(false, true, false);
   session2.start();
}
 
Example #8
Source File: ColocatedHAManager.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * update the backups configuration
 *
 * @param backupConfiguration    the configuration to update
 * @param name                   the new name of the backup
 * @param portOffset             the offset for the acceptors and any connectors that need changing
 * @param remoteConnectors       the connectors that don't need off setting, typically remote
 * @param journalDirectory
 * @param bindingsDirectory
 * @param largeMessagesDirectory
 * @param pagingDirectory
 * @param fullServer
 */
private static void updateSharedStoreConfiguration(Configuration backupConfiguration,
                                                   String name,
                                                   int portOffset,
                                                   List<String> remoteConnectors,
                                                   String journalDirectory,
                                                   String bindingsDirectory,
                                                   String largeMessagesDirectory,
                                                   String pagingDirectory,
                                                   boolean fullServer) {
   backupConfiguration.setName(name);
   backupConfiguration.setJournalDirectory(journalDirectory);
   backupConfiguration.setBindingsDirectory(bindingsDirectory);
   backupConfiguration.setLargeMessagesDirectory(largeMessagesDirectory);
   backupConfiguration.setPagingDirectory(pagingDirectory);
   updateAcceptorsAndConnectors(backupConfiguration, portOffset, remoteConnectors, fullServer);
}
 
Example #9
Source File: FileConfigurationTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testJournalFileOpenTimeoutValue() throws Exception {
   int timeout = RandomUtil.randomPositiveInt();
   Configuration configuration = createConfiguration("shared-store-master-hapolicy-config.xml");
   configuration.setJournalFileOpenTimeout(timeout)
                .setJournalDirectory(getJournalDir())
                .setPagingDirectory(getPageDir())
                .setLargeMessagesDirectory(getLargeMessagesDir())
                .setBindingsDirectory(getBindingsDir());
   ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
   try {
      server.start();
      JournalImpl journal = (JournalImpl) server.getStorageManager().getBindingsJournal();
      Assert.assertEquals(timeout, journal.getFilesRepository().getJournalFileOpenTimeout());
      Assert.assertEquals(timeout, server.getConfiguration().getJournalFileOpenTimeout());
   } finally {
      server.stop();
   }
}
 
Example #10
Source File: PrintData.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute(ActionContext context) throws Exception {
   super.execute(context);

   Configuration configuration = getParameterConfiguration();

   try {
      if (configuration.isJDBC()) {
         printDataJDBC(configuration, context.out);
      } else {
         printData(new File(getBinding()), new File(getJournal()), new File(getPaging()), context.out, safe);
      }
   } catch (Exception e) {
      treatError(e, "data", "print");
   }
   return null;
}
 
Example #11
Source File: PostOfficeJournalLoader.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public PostOfficeJournalLoader(PostOffice postOffice,
                               PagingManager pagingManager,
                               StorageManager storageManager,
                               QueueFactory queueFactory,
                               NodeManager nodeManager,
                               ManagementService managementService,
                               GroupingHandler groupingHandler,
                               Configuration configuration) {

   this.postOffice = postOffice;
   this.pagingManager = pagingManager;
   this.storageManager = storageManager;
   this.queueFactory = queueFactory;
   this.nodeManager = nodeManager;
   this.managementService = managementService;
   this.groupingHandler = groupingHandler;
   this.configuration = configuration;
   queues = new HashMap<>();
}
 
Example #12
Source File: JMSClusteredTestBase.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
/**
 * @return
 */
protected Configuration createConfigServer(final int source, final int destination) throws Exception {
   final String destinationLabel = "toServer" + destination;
   final String sourceLabel = "server" + source;

   Configuration configuration = createDefaultInVMConfig(source).setSecurityEnabled(false)
                                                                .setJMXManagementEnabled(true)
                                                                .setPersistenceEnabled(false)
                                                                .addConnectorConfiguration(destinationLabel, new TransportConfiguration(InVMConnectorFactory.class.getName(), generateInVMParams(destination)))
                                                                .addConnectorConfiguration(sourceLabel, new TransportConfiguration(InVMConnectorFactory.class.getName(), generateInVMParams(source)))
                                                                .addClusterConfiguration(new ClusterConnectionConfiguration().setName(destinationLabel)
                                                                                                                             .setConnectorName(sourceLabel)
                                                                                                                             .setRetryInterval(250)
                                                                                                                             .setMaxHops(MAX_HOPS)
                                                                                                                             .setConfirmationWindowSize(1024)
                                                                                                                             .setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND)
                                                                                                                             .setStaticConnectors(new ArrayList<String>() {
                                                                                                                                {
                                                                                                                                   add(destinationLabel);
                                                                                                                                }
                                                                                                                             }));

   configuration.getAddressesSettings().put("#", new AddressSettings().setRedistributionDelay(0));

   return configuration;
}
 
Example #13
Source File: LargeMessageOverManagementTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
   super.setUp();

   Configuration config = createBasicConfig();


   TransportConfiguration acceptorConfig = createTransportConfiguration(false, true, generateParams(0, false));
   config.addAcceptorConfiguration(acceptorConfig);
   server = createServer(true, config);
   server.setMBeanServer(mbeanServer);
   server.start();

   locator = createInVMNonHALocator().setBlockOnNonDurableSend(true);
   sf = createSessionFactory(locator);
   session = sf.createSession(false, true, false);
   session.start();
   addClientSession(session);
}
 
Example #14
Source File: AcceptorsTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultipleAcceptorsWithSameHostPortDifferentName() throws Exception {
   final String acceptorFactoryClass = FakeAcceptorFactory.class.getName();

   Map<String, Object> params = new HashMap<>();
   params.put("host", "localhost");
   params.put("port", 5445);

   Set<TransportConfiguration> tcs = new HashSet<>();
   tcs.add(new TransportConfiguration(acceptorFactoryClass, params, "Acceptor1"));
   tcs.add(new TransportConfiguration(acceptorFactoryClass, params, "Acceptor2"));

   Configuration config = createBasicConfig();
   config.setAcceptorConfigurations(tcs);

   ActiveMQServer server = createServer(config);

   server.start();
   waitForServerToStart(server);

   assertNotNull(server.getRemotingService().getAcceptor("Acceptor1"));
   assertNotNull(server.getRemotingService().getAcceptor("Acceptor2"));
}
 
Example #15
Source File: LiveCrashOnBackupSyncTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private Configuration createBackupConfiguration() throws Exception {
   Configuration conf = new ConfigurationImpl();
   conf.setName("localhost::backup");
   conf.setBrokerInstance(backupDir);
   ReplicaPolicyConfiguration haPolicy = new ReplicaPolicyConfiguration();
   haPolicy.setClusterName("cluster");
   conf.setHAPolicyConfiguration(haPolicy);
   conf.addAcceptorConfiguration("backup", "tcp://localhost:61617");
   conf.addConnectorConfiguration("live", "tcp://localhost:61616");
   conf.addConnectorConfiguration("backup", "tcp://localhost:61617");
   conf.setClusterUser("mycluster");
   conf.setClusterPassword("mypassword");
   ClusterConnectionConfiguration ccconf = new ClusterConnectionConfiguration();
   ccconf.setStaticConnectors(new ArrayList<>()).getStaticConnectors().add("live");
   ccconf.setName("cluster");
   ccconf.setConnectorName("backup");
   conf.addClusterConfiguration(ccconf);

   conf.setSecurityEnabled(false).setJMXManagementEnabled(false).setJournalType(JournalType.MAPPED).setJournalFileSize(1024 * 512).setConnectionTTLOverride(60_000L);
   return conf;
}
 
Example #16
Source File: HAPolicyConfigurationTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void colocatedTestNullBackup() throws Exception {
   Configuration configuration = createConfiguration("colocated-hapolicy-config-null-backup.xml");
   ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
   try {
      server.start();
      Activation activation = server.getActivation();
      assertTrue(activation instanceof ColocatedActivation);
      HAPolicy haPolicy = server.getHAPolicy();
      assertTrue(haPolicy instanceof ColocatedPolicy);
      ColocatedPolicy colocatedPolicy = (ColocatedPolicy) haPolicy;
      ReplicatedPolicy livePolicy = (ReplicatedPolicy) colocatedPolicy.getLivePolicy();
      assertNotNull(livePolicy);

      assertEquals(livePolicy.getGroupName(), "purple");
      assertEquals(livePolicy.getGroupName(), livePolicy.getBackupGroupName());
      assertEquals(livePolicy.getBackupGroupName(), haPolicy.getBackupGroupName());
      assertTrue(livePolicy.isCheckForLiveServer());
      assertEquals(livePolicy.getClusterName(), "abcdefg");
      ReplicaPolicy backupPolicy = (ReplicaPolicy) colocatedPolicy.getBackupPolicy();
      assertNotNull(backupPolicy);
   } finally {
      server.stop();
   }
}
 
Example #17
Source File: ClusterTestBase.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void setupClusterConnection(ClusterConnectionConfiguration clusterConf,
                                      final boolean netty,
                                      final int nodeFrom,
                                      final int... nodesTo) {
   ActiveMQServer serverFrom = servers[nodeFrom];

   if (serverFrom == null) {
      throw new IllegalStateException("No server at node " + nodeFrom);
   }

   TransportConfiguration connectorFrom = createTransportConfiguration(netty, false, generateParams(nodeFrom, netty));
   serverFrom.getConfiguration().getConnectorConfigurations().put(connectorFrom.getName(), connectorFrom);

   List<String> pairs = getClusterConnectionTCNames(netty, serverFrom, nodesTo);
   Configuration config = serverFrom.getConfiguration();
   clusterConf.setConnectorName(connectorFrom.getName()).setConfirmationWindowSize(1024).setStaticConnectors(pairs);

   config.getClusterConfigurations().add(clusterConf);
}
 
Example #18
Source File: ActiveMQServerControlImpl.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public ActiveMQServerControlImpl(final PostOffice postOffice,
                                 final Configuration configuration,
                                 final ResourceManager resourceManager,
                                 final RemotingService remotingService,
                                 final ActiveMQServer messagingServer,
                                 final MessageCounterManager messageCounterManager,
                                 final StorageManager storageManager,
                                 final NotificationBroadcasterSupport broadcaster) throws Exception {
   super(ActiveMQServerControl.class, storageManager);
   this.postOffice = postOffice;
   this.configuration = configuration;
   this.resourceManager = resourceManager;
   this.remotingService = remotingService;
   server = messagingServer;
   this.messageCounterManager = messageCounterManager;
   this.broadcaster = broadcaster;
   server.getManagementService().addNotificationListener(this);
}
 
Example #19
Source File: OpenwirePluginTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Override
protected ActiveMQServer createServer(boolean realFiles, Configuration configuration, int pageSize,
                                      long maxAddressSize, Map<String, AddressSettings> settings) {
   ActiveMQServer server = super.createServer(realFiles, configuration, pageSize, maxAddressSize, settings);
   server.registerBrokerPlugin(verifier);
   server.registerBrokerPlugin(new ActiveMQServerPlugin() {

      @Override
      public void afterCreateConnection(RemotingConnection connection) throws ActiveMQException {
         try {
            //Verify that calling getClientID() before initialized doesn't cause an error
            //Test for ARTEMIS-1713
            connection.getClientID();
         } catch (Exception e) {
            throw new ActiveMQException(e.getMessage());
         }
      }
   });

   configuration.getAddressesSettings().put("autoCreated", new AddressSettings().setAutoDeleteAddresses(true)
         .setAutoDeleteQueues(true).setAutoCreateQueues(true).setAutoCreateAddresses(true));

   return server;
}
 
Example #20
Source File: OpenwireArtemisBaseTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void setUpClusterServers(EmbeddedJMS[] servers) throws Exception {

      Configuration[] serverCfgs = new Configuration[servers.length];
      for (int i = 0; i < servers.length; i++) {
         serverCfgs[i] = createConfig(i);
      }

      for (int i = 0; i < servers.length; i++) {
         deployClusterConfiguration(serverCfgs[i], getTargets(servers.length, i));
      }

      for (int i = 0; i < servers.length; i++) {
         servers[i] = new EmbeddedJMS().setConfiguration(serverCfgs[i]).setJmsConfiguration(new JMSConfigurationImpl());
      }

      for (int i = 0; i < servers.length; i++) {
         servers[i].start();
      }

      for (int i = 0; i < servers.length; i++) {
         Assert.assertTrue(servers[i].waitClusterForming(100, TimeUnit.MILLISECONDS, 20, servers.length));
      }
   }
 
Example #21
Source File: FileConfigurationParserTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testParsingClusterConnectionURIs() throws Exception {
   FileConfigurationParser parser = new FileConfigurationParser();

   String configStr = firstPart + "<cluster-connections>\n" +
      "   <cluster-connection-uri name=\"my-cluster\" address=\"multicast://my-discovery-group?messageLoadBalancingType=STRICT;retryInterval=333;connectorName=netty-connector;maxHops=1\"/>\n" +
      "</cluster-connections>\n" + lastPart;
   ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8));

   Configuration config = parser.parseMainConfig(input);

   Assert.assertEquals(1, config.getClusterConfigurations().size());

   Assert.assertEquals("my-discovery-group", config.getClusterConfigurations().get(0).getDiscoveryGroupName());
   Assert.assertEquals(333, config.getClusterConfigurations().get(0).getRetryInterval());
}
 
Example #22
Source File: TwoBrokerFailoverClusterTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
   HashMap<String, String> map = new HashMap<>();
   map.put("rebalanceClusterClients", "true");
   map.put("updateClusterClients", "true");
   map.put("updateClusterClientsOnRemove", "true");
   Configuration config0 = createConfig("127.0.0.1", 0, map);
   Configuration config1 = createConfig("127.0.0.1", 1, map);

   deployClusterConfiguration(config0, 1);
   deployClusterConfiguration(config1, 0);

   server0 = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
   server1 = new EmbeddedJMS().setConfiguration(config1).setJmsConfiguration(new JMSConfigurationImpl());

   clientUrl = "failover://(" + newURI("127.0.0.1", 0) + "," + newURI("127.0.0.1", 1) + ")";

   server0.start();
   server1.start();
   Assert.assertTrue(server0.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
   Assert.assertTrue(server1.waitClusterForming(100, TimeUnit.MILLISECONDS, 20, 2));
}
 
Example #23
Source File: FileLockNodeManagerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
protected Configuration createDefaultInVMConfig() throws Exception {
   final Configuration config = super.createDefaultInVMConfig();
   if (useSeparateLockFolder) {
      config.setNodeManagerLockDirectory(getTestDir() + "/nm_lock");
   }
   return config;
}
 
Example #24
Source File: AcceptorControlTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testNotifications() throws Exception {
   TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
   TransportConfiguration acceptorConfig2 = new TransportConfiguration(NettyAcceptorFactory.class.getName(), new HashMap<String, Object>(), RandomUtil.randomString());
   Configuration config = createBasicConfig().addAcceptorConfiguration(acceptorConfig).addAcceptorConfiguration(acceptorConfig2);
   ActiveMQServer service = createServer(false, config);
   service.setMBeanServer(mbeanServer);
   service.start();

   AcceptorControl acceptorControl = createManagementControl(acceptorConfig2.getName());

   SimpleNotificationService.Listener notifListener = new SimpleNotificationService.Listener();

   service.getManagementService().addNotificationListener(notifListener);

   Assert.assertEquals(0, notifListener.getNotifications().size());

   acceptorControl.stop();

   Assert.assertEquals(usingCore() ? 7 : 1, notifListener.getNotifications().size());

   int i = findNotification(notifListener, CoreNotificationType.ACCEPTOR_STOPPED);

   Notification notif = notifListener.getNotifications().get(i);
   Assert.assertEquals(CoreNotificationType.ACCEPTOR_STOPPED, notif.getType());
   Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());

   acceptorControl.start();

   i = findNotification(notifListener, CoreNotificationType.ACCEPTOR_STARTED);
   notif = notifListener.getNotifications().get(i);
   Assert.assertEquals(CoreNotificationType.ACCEPTOR_STARTED, notif.getType());
   Assert.assertEquals(NettyAcceptorFactory.class.getName(), notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString());
}
 
Example #25
Source File: FailoverTimeoutTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
   Configuration config = createConfig(0);
   server = new EmbeddedJMS().setConfiguration(config).setJmsConfiguration(new JMSConfigurationImpl());
   server.start();
   tcpUri = new URI(newURI(0));
}
 
Example #26
Source File: FileConfigurationTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private Configuration createConfiguration(String filename) throws Exception {
   FileConfiguration fc = new FileConfiguration();
   FileDeploymentManager deploymentManager = new FileDeploymentManager(filename);
   deploymentManager.addDeployable(fc);
   deploymentManager.readConfiguration();
   return fc;
}
 
Example #27
Source File: SharedStoreDontWaitForActivationTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void setupSharedStoreMasterPolicy(int node) {
   ActiveMQServer server = getServer(node);
   SharedStoreMasterPolicyConfiguration liveConfiguration = new SharedStoreMasterPolicyConfiguration();
   liveConfiguration.setFailoverOnServerShutdown(true);
   liveConfiguration.setWaitForActivation(false);

   Configuration config = server.getConfiguration();

   config.setHAPolicyConfiguration(liveConfiguration);
}
 
Example #28
Source File: CriticalSimpleTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleShutdown() throws Exception {

   Configuration configuration = createDefaultConfig(false);
   configuration.setCriticalAnalyzerCheckPeriod(10).setCriticalAnalyzerPolicy(CriticalAnalyzerPolicy.SHUTDOWN);
   ActiveMQServer server = createServer(false, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES);
   server.start();

   try {

      CountDownLatch latch = new CountDownLatch(1);

      server.getConfiguration().registerBrokerPlugin(new ActiveMQServerPlugin() {
         @Override
         public void criticalFailure(CriticalComponent components) throws ActiveMQException {
            latch.countDown();
         }
      });

      server.getCriticalAnalyzer().add(new CriticalComponent() {
         @Override
         public boolean checkExpiration(long timeout, boolean reset) {
            return true;
         }
      });

      Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
      Wait.waitFor(() -> !server.isStarted());


      Assert.assertFalse(server.isStarted());

   } finally {
      server.stop();
   }


}
 
Example #29
Source File: MessagePriorityTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
   super.setUp();
   Configuration config = createDefaultInVMConfig();
   server = addServer(ActiveMQServers.newActiveMQServer(config, false));
   server.start();
   locator = createInVMNonHALocator().setBlockOnNonDurableSend(true).setBlockOnDurableSend(true);
   sf = createSessionFactory(locator);
   session = addClientSession(sf.createSession(false, true, true));
}
 
Example #30
Source File: ZeroPrefetchConsumerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public EmbeddedJMS createArtemisBroker() throws Exception {
   Configuration config0 = createConfig("localhost", 0);
   String coreQueueAddress = brokerZeroQueue.getQueueName();
   AddressSettings addrSettings = new AddressSettings();
   addrSettings.setQueuePrefetch(0);
   config0.getAddressesSettings().put(coreQueueAddress, addrSettings);
   EmbeddedJMS newbroker = new EmbeddedJMS().setConfiguration(config0).setJmsConfiguration(new JMSConfigurationImpl());
   return newbroker;
}